C scope-rules MCQ
Q1. The continue statement cannot be used with ______ ?
- for
- while
- do while
- switch
Answer:- (D).
Explanations :continue is used to skip the statements and can not be used with switch case.
Explanations :continue is used to skip the statements and can not be used with switch case.
- Bjarne Stroustrup
- James A. Gosling
- Dennis Ritchie
- Dr. E.F. Codd
Answer:- (C).
- AT & T Bell Laboratory
- MIT University
- Harvard University
- Stanford Lab
Answer:- (A).
#include <stdio.h> struct temp { int a[10]; char p; };
- 5
- 11
- 41
- 44
Answer:- (D).
- C structure is always 128 bytes
- Size of C structure is the total bytes of all elements of structure.
- Size of C structure is the size of largest elements
- 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.
Explanations :Individually calculate the size of each member of a structure and make a total to get full size of a structure.
- Derived datatype
- Secondary datatype
- Aggregate datatype
- All of the above
Answer:- (D).
#include <stdio.h> int main() { int x = 10; float x =10.0; printf("%d" , x); return 0; }
- 10.1
- Compilations Error
- 10
- 10
Answer:- (B).
Explanations :Since the variable x is defined both as integer and as float, it results in an error.
Explanations :Since the variable x is defined both as integer and as float, it results in an error.
- Variable names cannot start with a digit.
- Variable can be any length
- They can contain alphanumeric characters as well as special characters
- Reserved word can be used as variable name
Answer:- (A).
Explanations :Variable names cannot start with a digit in C programming language.
Explanations :Variable names cannot start with a digit in C programming language.
#include <stdio.h> int main() { int i; for(i=0; i < 5, i++) { int a = i; } printf("%d",a); return 0; }
- Syntax error in declaration of a
- No errors, program will show the output of 5
- Redeclaration of a in same scope throws error
- A is out of scope when printf is called
Answer:- (A).
#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; }
- p = 1 q = 1
- p = 1 q = 2
- p = 2 q = 2
- Invalid syntax
Answer:- (B).
Explanations :The comma operator evaluates both of its operands and produces the value of the second.
Explanations :The comma operator evaluates both of its operands and produces the value of the second.
- &&
- ||
- both i & ii
- !
Answer:- (D).
Explanations :! is a binary operator.
Explanations :! is a binary operator.
- Index value is retained outside the loop
- Index value can be changed from within the loop
- Goto can be used to jump, out of the loop
- All of these
Answer:- (D).
for( x = 1; x = 3; x
- Three times
- Four times
- Forever
- Never
Answer:- (D).
void main() { int num = 0; do { --num; printf("%d", num); num ++; } while(num >= 0); }
- A run time error will be reported
- The program will not enter into the loop
- The loop will run infinitely many times
- There will be a compilation error reported
Answer:- (C).
marks = 80; switch(marks) { Case 60: grade = 'C'; break; Case 70: grade = 'B'; break; Case 80: grade = 'A'; break; default: grade = 'E';
- A
- B
- C
- E
Answer:- (A).
- Loop Unrolling
- Strength reduction
- loop Concatenation
- 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.
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.
- 7
- 127
- 255
- No limits
Answer:- (D).
- char *
- struct
- void
- none of the mentioned
Answer:- (D).
- <stdio.h>
- <stdlib.h>
- <math.h>
- <stdarg.h>
Answer:- (D).
- int my_num = 100,000;
- int my_num = 100000;
- int my_num = 1000;
- int $my_num = 10000;
Answer:- (D).
Explanations :Space, comma and $ cannot be used in a variable name.
Explanations :Space, comma and $ cannot be used in a variable name.
- int number
- float rate
- int variable_count
- int $main;
Answer:- (d).
Explanations :Since only underscore and no other special characters is allowed in a variable name, it results in an error.
Explanations :Since only underscore and no other special characters is allowed in a variable name, it results in an error.
- immutable
- mutable
- const
- Volatile
Answer:- (D).
Explanations :const is a keyword constant in C programs.
Explanations :const is a keyword constant in C programs.
- File inclusion
- Selective inclusion
- Conditional compilation
- Recursive macros
Answer:- (D).
Explanations :Conditional compilation is the preprocessor facility to produce a different executable.
Explanations :Conditional compilation is the preprocessor facility to produce a different executable.
- #
- $
- " "
- &
Answer:- (A).
Explanations : The C-preprocessor are specified with # symbol.
Explanations : The C-preprocessor are specified with # symbol.
- for
- while
- do-while
- all of the mentioned
Answer:- (D).