C scope-rules MCQ


Q1. The continue statement cannot be used with ______ ?
  1. for
  2. while
  3. do while
  4. switch

Answer:- (D).
Explanations :continue is used to skip the statements and can not be used with switch case.
Q2.Who is father of C Language?
  1. Bjarne Stroustrup
  2. James A. Gosling
  3. Dennis Ritchie
  4. Dr. E.F. Codd

Answer:- (C).
Q3.C Language was developed at ?
  1. AT & T Bell Laboratory
  2. MIT University
  3. Harvard University
  4. Stanford Lab

Answer:- (A).
Q4. What will be the size of the following structure ?
#include <stdio.h>
struct temp {
 int a[10];
 char p;
};
  1. 5
  2. 11
  3. 41
  4. 44

Answer:- (D).
Q5. What is the size of a structure ?
  1. C structure is always 128 bytes
  2. Size of C structure is the total bytes of all elements of structure.
  3. Size of C structure is the size of largest elements
  4. None of the above

Answer:- (B).
Explanations :Individually calculate the size of each member of a structure and make a total to get full size of a structure.
Q6. A C structure of User defined datatype is also called_____ ?
  1. Derived datatype
  2. Secondary datatype
  3. Aggregate datatype
  4. All of the above

Answer:- (D).
Q7. What is the output of this program ?
#include <stdio.h>
int main() 
{
int x = 10;
float x =10.0;
printf("%d" , x);
return 0;
}
  1. 10.1
  2. Compilations Error
  3. 10
  4. 10

Answer:- (B).
Explanations :Since the variable x is defined both as integer and as float, it results in an error.
Q8. Which of the following is true for variable names in C ?
  1. Variable names cannot start with a digit.
  2. Variable can be any length
  3. They can contain alphanumeric characters as well as special characters
  4. Reserved word can be used as variable name

Answer:- (A).
Explanations :Variable names cannot start with a digit in C programming language.
Q9. What is the output of this program ?
#include <stdio.h>
int main()
{
int i;
for(i=0; i < 5, i++)
{
int a = i;
}
printf("%d",a);
return 0;
}
  1. Syntax error in declaration of a
  2. No errors, program will show the output of 5
  3. Redeclaration of a in same scope throws error
  4. A is out of scope when printf is called

Answer:- (A).
Q10. what is the output of the program ?
 #include<stdio.h>
 int main() 
 {
 int p, q, r, s;
 p = 1;
 q = 2;
 r = p,q;
 s = (p , q);
 printf("p = %d",p ,q);
 return 0;
 }
  1. p = 1 q = 1
  2. p = 1 q = 2
  3. p = 2 q = 2
  4. Invalid syntax

Answer:- (B).
Explanations :The comma operator evaluates both of its operands and produces the value of the second.
Q11. Which of the following is binary operator ?
  1. &&
  2. ||
  3. both i & ii
  4. !

Answer:- (D).
Explanations :! is a binary operator.
Q12. Which of the following statement about for loop is true ?
  1. Index value is retained outside the loop
  2. Index value can be changed from within the loop
  3. Goto can be used to jump, out of the loop
  4. All of these

Answer:- (D).
Q13. How long the following loop runs ?
for( x = 1; x = 3; x
  1. Three times
  2. Four times
  3. Forever
  4. Never

Answer:- (D).
Q14. If the following loop is implemented ?
void main() 
 {
 int num = 0;
 do {
 --num;
 printf("%d", num);
 num ++;
 }
 while(num >= 0);
 }
  1. A run time error will be reported
  2. The program will not enter into the loop
  3. The loop will run infinitely many times
  4. There will be a compilation error reported

Answer:- (C).
Q15. What is the value of 'grade' after the switch statement is executed ?
marks = 80;
 switch(marks) {
	 Case 60:
	 grade = 'C';
	 break;
	 Case 70:
	 grade = 'B';
	 break;
	 Case 80:
	 grade = 'A';
	 break;
	 default:
	 grade = 'E';
  1. A
  2. B
  3. C
  4. E

Answer:- (A).
Q16. In ______, the bodies of the two loops are merged together to form a single loop provided that they do not make any refrences to each other ?
  1. Loop Unrolling
  2. Strength reduction
  3. loop Concatenation
  4. Loop jamming

Answer:- (d).
Explanations : In loop jamming, the bodies of the two loops are merged together to form a single loop provided that they do not make any refrences to each other.
Q17. How many number of pointer (*) does C have against a pointer variable declaration ?
  1. 7
  2. 127
  3. 255
  4. No limits

Answer:- (D).
Q18. Which of the following return-type cannot be used for a function in C ?
  1. char *
  2. struct
  3. void
  4. none of the mentioned

Answer:- (D).
Q19. The standard header _____ is used for variable list arguments (_) in C ?
  1. <stdio.h>
  2. <stdlib.h>
  3. <math.h>
  4. <stdarg.h>

Answer:- (D).
Q20. Which is valid expression ?
  1. int my_num = 100,000;
  2. int my_num = 100000;
  3. int my_num = 1000;
  4. int $my_num = 10000;

Answer:- (D).
Explanations :Space, comma and $ cannot be used in a variable name.
Q21. Which of the following is not a valid C variable name ?
  1. int number
  2. float rate
  3. int variable_count
  4. int $main;

Answer:- (d).
Explanations :Since only underscore and no other special characters is allowed in a variable name, it results in an error.
Q22. Which keyword is used to prevent any changes in the variable within a C program ?
  1. immutable
  2. mutable
  3. const
  4. Volatile

Answer:- (D).
Explanations :const is a keyword constant in C programs.
Q23. Property which allows to produce different executable for different platforms in C is called ?
  1. File inclusion
  2. Selective inclusion
  3. Conditional compilation
  4. Recursive macros

Answer:- (D).
Explanations :Conditional compilation is the preprocessor facility to produce a different executable.
Q24. The C-preprocessors are specified with _______symbol.
  1. #
  2. $
  3. " "
  4. &

Answer:- (A).
Explanations : The C-preprocessor are specified with # symbol.
Q25. What is an example of iteration in C ?
  1. for
  2. while
  3. do-while
  4. all of the mentioned

Answer:- (D).