Sie sind auf Seite 1von 9

Introduction To C Language

1. Who invented the C - Programming? [A] James Gosling [B] Dennis Ritche [C] Bjarne Stroustrup's [D] Tim Berners-Lee Answer: Option [B] Explanation: Dennis Ritche invent c - programming between 1969 and 1973. 2. C is _______ language. [A] Low level [B] Middle Level [C] Machine Level [D] All Of Above Answer: Option [B] Explanation: C is High level language as well as business oriented language. 3. Where does C language get invented? [A] Ritche's Lab [B] AT & T Bell Labs [C] Under Oak Tree [D] Fringe Labs Answer: Option [B] Explanation: C language get invented at AT & T Bell Labs. 4. Which symbol terminates a C statement? [A] . [B] , [C] ; [D] } Answer: Option [C] Explanation: Semi Colon (;) terminates a C statement. 5. How to comment in C language? [A] //Comment [B] /* Comment */ [C] <---Comment----> [D] A&B Answer: Option [D] Explanation: // Comment is use for single line comment and /* */ is user for multiline comment. 6. Which is not a character of C? [A] $ [B] !
1

[C] ^ [D] ~ Answer: Option [A] Explanation: Doller $ is not the character set of C language. 7. Identify the scalar data type in C. [A] union [B] function [C] double [D] array Answer: Option [C] Explanation: double is the the scalar data type in C. 8. How many tokens are in the following: if(age==21) [A] 4 [B] 5 [C] 6 [D] 7 Answer: Option [C] Explanation: There are six tokens in if(age==21). 9. Which is an invalid variable name? [A] integer [B] Xx [C] net-total [D] sum Answer: Option [C] Explanation: net-total is the invalid variable name because - (minus) is used as a operator 10. C constants can be divided into _ categories? [A] 3 [B] 6 [C] 2 [D] 4 Answer: Option [C] Explanation: C constants can be divided into 2 major categories. 1) Primary constants 2) Secondary constants

Data Types:
1. [A] [B] [C] Identify the type(s) if data type. Scalar Drived Pointer
2

[D] All Of Above Answer: Option [D] Explanation: All are the type of data type. Scalar include integer, float, double, char. Derived include structure, union, array/string. Pointer is also data type. 2. What will be output when you will execute following c code? #include int main(){ printf("%d\t",sizeof(6.5)); printf("%d\t",sizeof(90000)); printf("%d",sizeof('A')); return 0; } [A] 421 [B] 821 [C] 842 Answer: Option [C] 3. integer datayape in c define by [A] int [B] integer Answer: Option [A] Explanation: integer datatype in c language define by int

Arrays
1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? [A] The compiler would report an error. [B] The program may crash if some important data gets overwritten. [C] The array size would appropriately grow. [D] The element will be set to 0. Answer: Option [B] Explanation: If the index of the array size is exceeded, the program will crash. Hence "option c" is the correct answer. But the modern compilers will take care of this kind of errors. Example: Run the below program, it will crash in Windows (TurboC Compiler) 2. What does the following declaration mean? int (*ptr)[10]; [A] ptr is a pointer to an array of 10 integers [B] ptr is array of pointers to 10 integers [C] ptr is an array of 10 integers [D] ptr is an pointer to array Answer: Option [A]

Structures and Union


1. Which of the following comment about the usage of structures in true? [A] Storage class can be assigned to individual member [B] Individual members can be initialized within a structure type declaration [C] The scope of the member name is confined to the particular structure, within which it is defined [D] None of above Answer: Option [C] Explanation: Structure is user defined data type which is used to store heterogeneous data under unique name. 2. Which of the following comment about Union is false? [A] Union is a structure whose members share same memory area [B] The compiler will keep track of what type of information is currently stored [C] Only one of the members of union can be assigned a value at particular time [D] Size allocated for Union is the size of its member needing the maximum storage Answer: Option [B] Explanation: Union is similar to structure the only difference is the way the memory allocated to structure and union 3. Which of the following is a collection of different data types? [A] String [B] Array [C] Structure [D] Files Answer: Option [C] Explanation: Structure is a user defined data type which contains the variables of different data types. 4. For accessing a structure element using a pointer,you must use? [A] Pointer operator (&) [B] Dot operators(.) [C] Pointer operator(*) [D] Arrow operator(->) Answer: Option [D] Explanation: For accessing the structure element using pointers arrow operator is used otherwise dot operator is used. 5. Which operator is used to connect structure name to its member name? [A] dot operator(.) [B] logical operator(&&) [C] pointer operator(&) [D] Arrow operator(->) Answer: Option [A]
4

6. In C, structure values can be passed as arguments to function by? [A] passing each member of the structure as an argument of function call [B] passing copy of the entire structure to the called function [C] passing structure as an argument using pointer [D] All of above Answer: Option [D] 7. A -> B is syntactically correct if? [A] a and b are structure [B] a is a structure and b is a pointer to structure [C] a is a pointer to structure and b is a structure [D] a is a pointer to structure in which b is a field Answer: Option [D] 8. What is the output of following C code? main() { struct emp { char name[20]; int age; float sal; }; struct emp e ={"Tiger"} printf("%d%d%f",e.age,e.sal); } [A] Error [B] Garbage Collection [C] 0 0.000000 [D] 1 0.000000 Answer: Option [C]

Basic Concepts
1. The value of automatic variable that is declared but not initialized will be? [A] 0 [B] 1 [C] Unpredictable [D] None of above Answer: Option [C] 2. Choose the correct statement [A] An identifier may start with an underscore [B] An identifier may end with an underscore
5

[C] IF is a valid identifier [D] All of above Answer: Option [D] 3. The const feature can be applied to? [A] An identifier [B] An array [C] An array argument [D] All of above Answer: Option [D] 4. The expression 5-2-3*5-2 will evaluate to 18 if ? [A] - is left associative and * has precedence over [B] - is right associative and * has precedence over [C] - is right associative and - has precedence over * [D] - if left associative and - has precedence over * Answer: Option [C] 5. C language has been developed by ? [A] . Dennis Ritchie [B] Peter Norton [C] Ken Thompson [D] Martin Richards Answer: Option [A] 6. Smallest element of Array Index is called [A] Lower Bond [B] Upper Bond [C] Extraction [D] Rang Answer: Option [A] 7. Cons feature can be applied on [A] identifier [B] array [C] Array Argument [D] Function Answer: Option [C] 8. Is it true that a global variable may have several declarations, but only one definition? [A] Yes [B] No Answer: Option [A] Explanation: Yes, In all the global variable declarations, you need to use the keyword extern.

Functions
1. The default parameter passing mechanism is ? [A] Call by value [B] Call by reference [C] Call by value result [D] None of above Answer: Option [A] 2. The order in which actual arguments are evaluated in function call [A] is from the left [B] is from the right [C] is compiler dependent [D] None of above Answer: Option [C] 3. Use of functions ? [A] Helps to avoid repeating a set of statements many times [B] Enhance the logical clarity of the program [C] Helps to avoid repeated programming across program [D] All of above Answer: Option [D] 4. Forward declaration is absolutely necessary? [A] if a function returns a non integer quantity [B] if the function call precedes its definition [C] if the function call precedes its definition and the function returns a non integer quantity [D] None of above Answer: Option [C] 5. Any C program [A] Must contain at least one function [B] Need not contain any function [C] Needs input data [D] None of above Answer: Option [A] 6. Call by reference is also known as ? [A] Call by address or Call by location [B] Call by address or Call by value [C] Call by value or Call by name [D] None of above Answer: Option [A]

Control Structures
1. In a for loop, if the condition is missing,then? [A] it is assumed to be present and taken to be false [B] it is assumed to be present and taken to be true [C] it result in the syntax error [D] execution will be terminated abruptly Answer: Option [B] 2. In a for loop, if the condition is missing, then infinite looping can not be avoided by a [A] Continue statement [B] goto statement [C] return statement [D] break statement Answer: Option [A] 3. Choose the correct statement [A] 0 represent a false condition [B] Non zero value represent a false condition [C] 1 represent a false condition [D] Anything that is not 1, represents a false condition Answer: Option [A] 4. Which of the following comments about for loop are not correct? [A] Index value is retained outside the loop [B] Index value can be changed from within the loop [C] goto can be used to jump,out of loop [D] Body of the loop can not be empty Answer: Option [D] 5. Which of the following comment about for loop are correct? [A] Using break is equivalent to using a goto that jumps to the statement immediately following the loop [B] Continue is used to by pass the remainder of the current pass of the loop [C] if comma operator is used,then the value returned is the value of the right operand [D] All of above Answer: Option [D] 6. Break statement can be simulated by using ? [A] goto [B] return [C] exit [D] any of the above statement Answer: Option [A]
8

Operators
1. Which of the following operator takes only integer operands? [A] + [B] * [C] / [D] % Answer: Option [D] 2. Pick the operator that not associates from the left? [A] + [B] [C] = [D] < Answer: Option [C] 3. Pick the operator that not associates from the right? [A] ?: [B] += [C] =\ [D] != Answer: Option [D] 4. The operators .,!!,<,= if arranged in ascending order of precedence reads ? [A] .,!!,<,= [B] =,<,!!,. [C] =,!!,<,. [D] <,!!,=,. Answer: Option [C] 5. Which of the following comment about the ++ operator are correct? [A] It is unary operator [B] The operand can come before or after the operator [C] It cannot be applied to an expression [D] All of above Answer: Option [D]

Das könnte Ihnen auch gefallen