0% found this document useful (0 votes)
2 views13 pages

C Language Basics Quiz Questions

Mock

Uploaded by

rohitpatel165
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

C Language Basics Quiz Questions

Mock

Uploaded by

rohitpatel165
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. ‘C’ is a ________level language.

1) high 2) low 3) middle 4) maching

2. ‘C’ Language is developed by _________.

1) Dennis Ritchie 2) Ken Thompson


3) Stroustrup 3) Kernighan Ritche

3. The maximum length of an identifier is___________.

1) 10 char 2) 32 char 3) 8 char 4) Compiler dependant

4. Which of the following is a valid identifier?

1) 26 July 2) 26-July 3) 26_July 4) _26July

5. Find invalid rule for an identifier

1) It can start & end with alphabet


2) It can start & end with digit character
3) It can start & end with underscore
4) All are valid rules

6. Which of the following is not a keyword of C?

1) int 2) void 3) main 4) goto

7. Which of the following statements are true regarding arithmetic operators?

i) An arithmetic operation between an integer and an integer yields an integer


ii) An arithmetic operation between two floats yields an integer
iii) An arithmetic operation between an integer and a float yields an integer
iv) An arithmetic operation between an integer and a float yields a float

1) i and iii 2) ii and iv 3) ii and iii 4) i and iv

8. Which of the following are format specifies?

i) %f ii) %c iii) %q iv) %z v) %u

1) i, ii, iv & v 2) ii, iii, iv % v 3) i, ii & v 4) i, ii, iii & iv

9. Which characters are used for multiline commenting?

1) \**/ 2) /**/ 3) /** \ 4) \**\


9. Where can I write #include statement?

1) at the start of program


2) at the start of function
3) anywhere in function
4) anywhere in program, but # should be 1st char. on that line

10. Which files contain prototype of standard (library) function?

1) .c 2) .obj 3) .h 4) .cpp

11. Block of statements are enclosed in

1) [ ] 2) ( ) 3) { } 4) < >

12. Statement of C ends with

1) } 2) / 3) \ 4) ;

13. When memory is allocated to variables of a program?

1) when we write program


2) when we save program
3) when we compile program
4) when we execute program

14. We can not have variables of type_______.

1) void 2) short int 3) signed char 4) long double

15. What getch( ) does?

1) gets char from file


2) gets char from user & shows it on screen
3) gets char from user & does not show on screen
4) shows output to user

16. Data stored in Computer’s memory is in_______.

1) decimal 2) character 3) hexadecimal 4) binary

17. void main( )


{ printf(“%d”, sizeof(char));
printf(“%d”, sizeof(int));
printf(“%d”, sizeof(float));
}

1) 1 4 4 2) 2 4 4
3) 1 2 4 4) Error : invalid parameter to sizeof
18. int x = 10;
void main( )
{printf(“%d”,x);
{int x =20;
{ int x =30;
printf(“%d”,x);
}
printf(“%d”,x);
}
}

1) 10 20 30 2) 10 30 20 3) 10 30 30 4) Error

19. void main( )


{ char ch='12';
printf(“%d”, ch );
}

1) 1 2) 12 3) 49 4) Error

20. void main( )


{
printf(“%d %d %d”, 8 );
}

1) 8 garbage garbage 2) 8 8 garbage


3) 8 0 garbage 4) Error

.
21 void main( )
{ float f=5.4;
if(f= =5.4) printf(“equal”);
else printf(“not equal”);
printf(“%f”, f);
}

1) equal 2) not equal 5.400000


3) not equal 4) 5.400000

22. void main( )


{ int a=2, b=3;
if(a=b); printf(“equal”);
else printf(“not equal”);
}
1) not equal 2) equal 3) No output 4) Error
23. void main( )
{ int a=2,b=3;
if(a>b);
printf(“*”);
printf(“+”);
}

1) * 2) + 3) *+ 4) no output

24. void main( )


{ int a=2,b=5,c=1;
if(a>b)
if(a>c) printf(“*”);
else printf(“*”);
printf(“+”);
}

1) *+ 2) **+ 3) *** 4) +

25. void main( )


{ int k=1,b=0,c=++b;
if( k-- >0 ) printf(“*”);
else printf(“+”);
print(“%d”, k);
}

1) *0 2) +0 3) *1 4) +1

26. void main( )


{ int a=0,b=1;
if(++a= =--b) printf(“%d %d”, --a, b++);
else printf(“%d %d”, a--, ++b);
}

1) 0 1 2) 0 0 3) -1 0 4) 1 1

27. if(a>b) b=a;


if(c>b) b=c;
printf(“%d”, b);
What is represented by above code?

1) it prints value of b as it is
2) it prints minimum of 3 nos. a, b, c
3) it prints maximum of 3 nos. a, b, c
4) it prints average of 3 nos. a, b, c

28. What is not a loop in C?


1) for 2) While 3) repeat until 4) do while
29. The statements which are repeated in loop are called

1) loop statements 2) loop expression


3) loop condition 4) initialization

30. What is not used to control loop iterations?

1) loop statements 2) loop expression


3) loop condition 4) initialization

31. Who allows control to flow inside or outside loop?

1) loop statements 2) loop expression


3) loop condition 4) initialization

32. Which part of loop executes only once?

1) 1) loop statements 2) loop expression


3) loop condition 4) initialization

33. In worst case, how many times will do – while loop executes (minimum)?

1) 0 2) 1 3) n times 4) infinite
. 33. In worst case, how many times while loop executes (minimum)?

1) 0 2) 1 3) n times 4) infinite
34. Missing condition in for loop will generate__________.

1) Compiler error 2) Runtime error


3) Warning 4) Infinite loop

[Link] condition in while loop will generate__________.

1) Compiler error 2) Runtime error


3) Warning 4) Infinite loop

36. Which statement can stop the loop?

1) continue 2) break 3) initialization 4) if

37. In for(…) how many semicolons are allowed?

1) <=2 2) exactly 2 3) >=2 4) >=0

38. In do while loop, 5th time condition is checked & now resulted into false, so how
many times loop has executed?

1) 4 2) 5 3) 6 4) 0
39. void main( )
{ int k=3;

while(k)
{int k=1;
printf(“%d ”, k);
k--;
}
k--;
}

1) 1 2) 3 2 1 3) Infinite loop 4) Error

40. void main( )


{ int i=0;
for(;i=2;) { printf(“%d ”, i); i++; }
}
1) 0 2) 0 1 2 3) 0 1 4) Infinite loop

41. void main( )


{ int i=0;
for(;i<=3; printf(“%d ”, ++i ) );
}

1) 1 2 3 2) 1 2 3 4 3) 0 1 2 3 4) Error

42. void main( )


{ int x=3;
do
{printf(“%d ”, x--);
}while(x&&0);
}

1) 3 2) 3 2 1 3) 2 1 4) none

43. void main( )


{ int i=0;
for(;i<=5;) printf(“%d ”, i=i*2);
}

1) 0 2 4 2) 0 1 2 3 4 5
3) 0 is printed infinitely 4) Error

44. void main( )


{ int j=1;
for(;j<=3; j++) printf(“%d”, j);
}

1) 0 2) 123 3) Inifinite loop 4) No output


45. void main( )
{ int i, j;
for(i=1; i<=3; i=i+2)
for(j=1; j<=3; j=j+2)
printf(“%d”, i+j );
}

1) 2 4 4 6 2) 1 2 2 3 3) Infinite loop 4) No output

46. void main( )


{ int i=0, j=0;
while(j= =i)
{ printf(“%d %d ”, i, j);
i++; j--;
}
}

1) 1 1 2) 0 1 0 1 0 1 3) 0 0 4) Infinite loop

47. Which is the following statement are correct regarding arrays?

i) Array elements are stored in contiguous memory locations


ii) Size of array can be mentioned anywhere in the program
iii) The Expression arr[i] refers to i+1 element in array arr

1) All are true 2) i only 3) i and iii 4) Nothing is true

48. What is used to access individual element of an array?

1) ( ) 2) [ ] 3) { } 4) ->

49. Indexing of array starts from

1) 1 2) size-1 3) 0 4) depends on compiler

50. ________dimensional array is not possible.

1) 0 2) 2 3) 3 4) 6

51. A[j] is not same as________.


1) *(A+j) 2) *(j+A) 3) j[A] 4) A+j

52. int num[5];


Num[5]
What is true about above two statements?

1) 1st statement indicates element & 2nd indicates array size


2) 1st statement indicates array size & 2nd indicates element
3) Both statements indicate array size
4) Both statements indicate element of an array
53. void main( )
{ int a[ ]={20,30,40,50,60}, *j=a;
j+=3;
printf(“%d”,*j);
}

1) 50 2) 20 3) 40 4) Compilation error
54. void main( )
{ char p[5]={0,0,65,66};
printf(“%d %d”, p[1], p[4]);
}

1) 0 66 2) 0 0 3) 0 garbage 4) Error
55. void main( )
{ int a[ ]={10,20,30,40,50}, j;
for(j=0; j<5; j++) printf(“%d”,*a);
}

1) 10 10 10 10 10
2) 10 20 30 40 50
3) Garbage value printed 5 times
4) Error : L value required
56. void main( )
{ int n[3][3]={2,4,6,8,5,3,5,1}, *ptr ,i;
Ptr=&n[1][0];
for(i=0;i<=3;i++) printf(“%d”, *(ptr+i));
}

1) 8 5 3 5 2) 5 3 5 1 3) 3 6 8 5 4) 6 3 garbage garbage

57. which statement is true regarding function?

1) Any C program contains at least one function


2) A function can be defined inside another function.
3) In a C program there can be more than one functions with the same name
4) A C program can be written without functions

58. The declaration “void fun(int);” indicates that the function

1) returns a float value 2) has no arguments


3) returns nothing 4) has default arguments

59. What is true regarding a return statement in a function?

1) There cannot be more than one return statements in a function


2) A return statement must be written at the end of the function
3) A function may not have return statement
4) All the above are true
60. How many values can be returned from a function using return statement?

1) only 1
2) maximum 2
3) As many we want, by writing more than one return statements
4) As many we want, by using comma operator
61. Parameters passed in a function call are called_____.

1) Formal Parameters 2) Receiving Parameters


3) Local Parameters 4) Actual Parameters
62. Which following statement is false about parameters?

1) Formal Parameters should be same as actual parameters


2) Actual Parameters should be same as formal parameters
3) Number of Actual & formal parameters should be same
4) Data type sequence of actual parameters should be same as formals
63. A function has by default returning data type______.

1) void 2) char 3) int 4) none of these


64. What is true regarding a returning data type of a function?

1) Function without returning data type can not return a value


2) Function having returning data type void can return a value
3) Function having returning data type void can not have return statement
4) 1, 2 & 3 are false
65. void C( ) { printf(“C”); }
void B( ) { C( ); printf(“B”); }
void A( ) { printf(“A”); B( ); }
void main( ) { printf(“M”); A( ); }

1) CAMB 2) MABC 3) MCAB 4) MACB

66. int transfer(int a, int b)


{ char t=1;
t=a; a=b; b=t;
return a;
return b;
}
void main( )
{ int x=2,y=3;
x=transfer(x,y);
printf(“%d %d”, x, y);
}

1) 2 3 2) 3 2 3) 2 2 4) 3 3
67. void main( )
{ printf(“main”);
f1( )
{printf(“f1”);
}
printf(“end”);
}

1) main 2) main end 3) main f1 end 4) Error


68. void call(int i)
{ printf(“%d”, i++);
if(i= =3) call(i);
}
void main( ) {int x=2; call(x); }

1) 2 2) 2 3 3) 3 4) 2 is printed infinitely

69. int check(int x, int y)


{ if(x= =y) { y=x+1; return(y); }
else {x=y+1; return(x); }
}
void main( )
{ int a=3,b=5;
printf(“%d”,check(a+b));
}

1) 9 2) 8 3) 5 4) 3

70. int sum(int a, int b)


{ if(a= =b) return (a+b)
else return(a-b);
}
void main( )
{ static int x;
x=sum(x,1);
printf(“%d”, x);
}

1) -1 2) 1 3) 2 4) 0
71. int add(int a, int b);
void main( )
{ int x;
x=add(21, 81);
x=add(x, 1);
printf(“%d”, x);
}
int add(int a, int b)
{int q;
q=a+b;
return(a, b);
}

1) 102 2) 1 3) 81 4) Error
72. int sub(int c, int d)
{ int x,y;
x=c-d;
y=c+d;
return(x, y);
}
void main( )
{ int i=10 j=20,k;
k=sub(i,j);
printf(“%d”, -k);
}

1) 10 2) -10 3) -30 4) 30

73. Pointer can store_______.

1) data 2) any address


3) data or address 4) any valid address and NULL

74. Which arithmetic operator is allowed with pointer?

1) * 2) / 3) % 4) +
75. What is the size of char **p ?

1) 0 bytes 2) 1 byte 3) 2 bytes 4) 4 bytes

76. A[ i ] is same as

1) *( A + i ) 2) *( i + A ) 3) i [ A ] 4) all of them ( 1, 2, 3 )
77. Which operator is used to access structure member through pointer?

1) * 2) . 3) -> 4) =>
78. Consider declaration int *P;
Which of the following statement will generate Error?

1) *++P 2) ++*P 3) *P++ 4) P*++

79. void main( )


{ char far *cash,*cheque;
printf(“%d %d”, sizeof(cash), sizeof(cheque));
}

1) 2 2 2) 2 4 3) 4 2 4) 4 4

80. void main( )


{ int a[ ]={1,2,3,4,5},j;
for(j=0; j<5; j++)
{ printf(“%d”, *(a+j)); a++;
}
}
1) 1 2 3 4 5 2) 1 2 3 4 3) 1 3 4) Compilation error

81. What is the difference between ‘=’ and ‘= =’ operators?

1) = is a assignment operator, whereas = = is a logical operator,


2) = assigns value, whereas = = compares two quantities
3) – should be used only for assigning integer values to identifiers, whereas = = can be
used to assign char, float values to identifiers.
4) Both operators mean same when used in condition.

82. Which operator works like if else?

1) : : 2) ? : 3) -> 4) >>

83. Which operators can be used to form a condition?

1) Relational 2) Relational & logical


3) Logical & arithmetic 4) All operators in C

84. Which operator cannot be used for joining two conditions?

1) && 2) || 3) ! 4) both 1 and 2

85. What is most false about switch?

1) All cases require continue


2) All cases require break
3) Last case doesn’t require break
4) First case may not have break

86. Switch can not handle_______data type


1) char 2) int 3) float 4) float & double

87. switch is preferred over nested if-else because

1) It increases complexity of a program


2) It improves execution speed of a program
3) It increases readability of a program
4) It reduces size of compiled code

88. Which character is used in switch to separate case from its action part

1) blank 2) : 3) ; 4) ,
89. void main( )
{ int m=10, n=15;
if(!(!m)&&m) printf(“%d”, m++);
else printf(“%d”, n++);
}

1) 15 2) 10 3) 16 4) 11

You might also like