Showing posts with label C. Show all posts
Showing posts with label C. Show all posts

Fundamental Small Question 2 (Answer)

Answer of Fundamental Small Question 2


1. How is character constant represented?

Ans:- A Character constants is written within single quotes. For example, ‘K’, ‘\’, and ‘5’.

2. How is string constant represented?

Ans:- A string constants is a sequence of zero or more characters enclosed within double quotes. For example, “X”, “656”, “ ”, and “RAJ”.

3. List the printable escape sequences.

Ans:- These are printable escape sequence : \\, \”, \’, and \?.

4. List the non graphic escape sequences.

Ans:- These are the non-graphic escape sequence :

\0 :- null character

\a :- alert

\b :- backspace

\t :- horizontal tab

\n :- new line

\v :- vertical tab

\f :- form feed

\r :- carriage return

5. What is the symbolic constant?

Ans:- If a constants is given a name, it becomes a symbolic constant or manifest. For example,

#define MAX 20

Defines the symbolic constant MAX to represent the constant value 20.

6. How is variable declared?

Ans:- Format (syntax):-

Data_type var1, var2, var3,……..,varn;

Ex.:- int a, b; float x, y;

7. What is initialization of a variable?

Ans:- If a variable is assigned a value in the declaration itself, it is known as initialization. For example,

Int x = 10, y = 5;

8. How are comments included in a C program?

Ans:- Single line or multiline comments are included between /* and */. Nested comments are not allowed in ANSI C. For example,

/* This is a function */

9. List white space characters in C.

Ans:- Blank space, new line, horizontal tab, vertical tab, carriage return and form feed are white space characters in C.

10. What is statement terminator? What is separator?

Ans:- Each statement is ended with a semicolon, so a semicolon is a statement terminator. Whereas, a white space character or a comment is a separator used to separate tokens.

11. List the token in C.

Ans:- Identifiers, keywords, constants, string constants, operators and separators are C tokens.

12. Identify the tokens in the expression if(mark >= 50).

Ans:- Here:

The keyword if is a token, the character ( is the next token, the variable mark is the subsequent token, the operator >= is the next token, the constant 50 is the next token, and the character ) is the next token.

13. What are lvalue and rvalue?

Ans:- Each variable has got two values, which are left value and right value whose short names are lvalue and rvalue. The lvalue denotes an object that is the address of the data object. The rvalue is the value residing in that address. An lvalue represents a memory location where a value may be stored; it denotes an object that refers to a storage location of the data object. The term lvalue is used, based on the principle of its appearance, on the left side of an assignment statement. Consider the following statements:

Int x, y;

X = 5;

Y = X;

In the first assignment statement, X is an lvalue. Hence, X is treated as a name for a particular memory location and the value 5 is stored in the memory location. In the second assignment statement, X is not an lvalue and hence the value stored in the memory location is referred to, by X. Thus, in some statements an operand must be an lvalue. If an lvalue appears in any other context, it is replaced by the value stored in that memory location.

14. What is the value of sizeof(char)?

Ans:- The value returned by sizeof(char) is always 1 since char uses only one byte in any machine. For other data types, the number of bytes used to represent a data type depends on the implementation of a compiler.

15. What is the current version of C?

Ans:- C99 is the current version of C. The character set is changed by supporting Unicode characters in this version. It includes additional data types, such as bool, complex, variable-length arrays, and variable structure members and some more new syntax also. Since there is a substantial change, most compilers have not yet implemented C99. The specification of new C99 may be obtained from ISO web site.



Fundamental Small Question 1 (Answer)

Answer of Fundamental Small Question 1


1. Who developed C language?

Ans:- Dennis Ritchie at AT & T Bell Laboratory, Murray Hill, New Jersey Developed C in 1972.

2. Why is C named of this language?

Ans:- The “C” name of this language is represent it as the successor of B language.

3. Who developed B language?

Ans:- Ken Thompson in 1970 developed B for the first UNIX system on the DEC PDP-7 computer.

4. Give the silent features of C.

Ans:- C is general purpose, free format and structured programming language. It has a rich set of operators, and uses more control structures. Memory addresses are directly accessed by using pointers. It is quite suitable for system programming. It is flexible and powerful language. It is fast running, machine independent and efficient language.

5. What are the limitations of C?

Ans:- There is no uniformity in associativity and no direct I/O facility.

6. Give the name any five C compiler?

Ans:- The name of five ‘C’ compilers:-

(i) Turbo C

(ii) Microsoft C

(iii) Quick C

(iv) Lattice C

(v) Power C

7. Give the character set of C.

Ans:- Alphabets : A to Z and a to z

Digits : 0 to 9

Special Characters : + - * / % = < > _ blank : ; , . ‘ “ ? ! # \ ( ) [ ] { } & | ^ ~

8. List out the name of C language reserved words.

Ans:- ANSI C keywords are listed below:

auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, If, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.

9. What is the purpose of a variable and a constant in a programming language?

Ans:- The data are represented using variable or constants in a programming language.

10. Give the name of scalar data types in C.

Ans:- Scalar data types in C are int, char, float and double.

11. Give the name of derived data types in C.

Ans:- Derived data types in C are array, function, pointers, structure and unions.

12. What are qualifiers in C?

Ans:- Qualifiers or modifiers are identifiers that may precede the scalar data types (except float) to specify the number of bits used for representing the respective type of data in memory. The qualifiers in C are short, long, signed and unsigned.

13. Give the name of type specifiers in C.

Ans:- Name of the type specifiers which is used in C : char, int, float, double, short, long, signed and unsigned.

14. Give the name of type of constant in C.

Ans:- The name of type of constants which is used in C : Integer constant, single and double precision constants, character constants, string constants and symbolic constants.

15. How are octal and hexa decimal constants are represented?

Ans:- Octal constants are preceded by zero and they are formed by using digits 0 to 7.

For example, 056 and 063.

Hexa constants are preceded by 0x or 0X. They are formed by using digits 0 to 9 and characters A to F or a to f.

For example, 0x532 and 0xa1c3.