Q5.Which of the following keyword is not used for variable naming in C?
a) export
b) friend
c) import
d) volatile
Answer: d
Explanation: volatile is C keyword.
Q6.Which is valid C expression?
a) int $my_num = 10000;
b) int my num = 1000;
c) int my_num = 100000;
d) int my_num = 100,000;
Answer: c
Explanation: according to naming convention of variable in C the Space, comma and $ cannot be used in a variable name.
Q7.What is short int in C programming?
a) The basic data type of C
b) int is the basic data type and Short is the qualifier
c) Qualifier
d) All of the mentioned
Answer: b
Q8.Which one of the following is wrong variable declaration in C?
a) float str = 3e2;
b) Both “float str = 3e2;” and “String str;”
c) String str;
d) char *str;
Answer: c
Explanation: String str declaration is only legal in Java not in C language.
Q9.Which one of the keyword given following is used to prevent any changes in the variable within a C program?
a) const
b) volatile
c) immutable
d) mutable
Answer: a
Explanation: const is a keyword in c used to declare constants.
Q10.What is the result of relational or logical expression in C?
a) False or True
b) gives 0 if an expression is false and positive number if the expression is true
c) 0 or 1
d) None of the mentioned
Answer: c
Q11.Which of the following typecasting is accepted in C ?
a) Widening conversions
b) Widening & Narrowing conversions
c) Narrowing conversions
d) None of the mentioned
Answer: b
Q12.In Which of the following statement the order of precedence of operators do not exist?
a) Within a macro definition
b) Within conditional statements, if, else
c) Within while, do-while
d) None of the mentioned
Answer: d
Q13.which of the following is wrong to use any Two operator in C?
a) different associativity and different precedence
b) different precedence and same associativity
c) same precedence and different associativity
d) All of the above
Answer: c
Q14.Which is the example of iterative statement in C?
a) for loop
b) while loop
c) do-while loop
d) all of the above
Answer: d
Q15.Can function return enumeration constants in C?
a) true
b) its depends on the compiler
c) false
d) its depends on the standard
Answer: a
Q16.A functions in C is _________
a) external
b) internal
c) both Internal and external
d) Internal and External are not legal terms for functions.
Answer: a
Q17.Which one is not correct in C?
a) static a = 10;
b) static static int a;
c) static int func (int);
d) all of the mentioned
Answer:b
Q18.What is the name of the C property that allows you to create different executable for different platforms?
a) File inclusion
b) Selective inclusion
c) Conditional compilation
d) Recursive macros
Answer: c
Q19.What is #include <stdio.h>?
a) preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
Answer: a
Q20.C pre-processors can have compiler specific features.
a) True
b) False
c) Depends on the standard
d) Depends on the platform
Answer: a
Q21.Which of the following are C preprocessors?
a) #ifdef
b) #define
c) #endif
d) all of the mentioned
Answer: d
Q22.Which symbol is used to specify the C-pre-processors?
a) #
b) $
c) ” ”
d) &
Answer: a
Q23.How is search done in #include and #include “somelibrary.h” according to C standard?
a) When former is used, current directory is searched and when latter is used, standard directory is searched
b) When former is used, standard directory is searched and when latter is used, current directory is searched
c) When former is used, search is done in implementation defined manner and when latter is used, current directory is searched
d) For both, search library errors occurring in implementation areas
Answer: b
Q24.How many number of pointer (*) does C have against a pointer variable declaration?
a) 7
b) 127
c) 255
d) No limits
Answer: d
Q25.Which of the array is not possible in C?
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array
Answer: a
Q26.Which one of the following is invalid return type in C?
a) char *
b) struct
c) void
d) none of the mentioned
Answer: d
Q27.What are the the standard header file is used for variable list arguments (…) in C.
a) <stdio.h>
b) <stdlib.h>
c) <math.h>
d) <stdarg.h>
Answer: d
Q28.When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
a) Standard input
b) Standard output
c) Standard error
d) All of the mentioned
Answer: d
Q29.In C , FILE is data type of ______.
a) int
b) char *
c) struct
d) None of the mentioned
Answer: c
Q30.What is the sizeof(char) in a 32-bit C compiler?
a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes
Answer: c
Q31.Which is the valid operator in C?
a) ,
b) sizeof()
c) ~
d) all of the above
Answer: d
Q32.scanf() is a predefined function in______header file.
a) stdlib. h
b) ctype. h
c) stdio. h
d) stdarg. h
Answer: c
Q33.What is the meaning of ‘a’ in the following syntax?
fp = fopen("Random.txt", "a");
a) Attach
b) Append
c) Apprehend
d) Add
Answer: b
Q34.what is the correct output of the following C code?
#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value
Answer: a
p>Q35.What is true if we compile and execute the following C code ?
#include <stdio.h>
int main()
{
int main = 3;
printf("%d", main);
return 0;
}
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run successfully without any error and prints 3
d) It will experience infinite looping
Answer: c
Q36.Study the following C code and find the correct output.
#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned
Answer: b
Explanation: The range of signed character is from -128 to +127. Since we are assigning a value of 128 to the variable ‘chr’, the result will be negative. 128 in binary is represented as “1000 0000” for character datatype. As you can see that the sign bit is set to 1, followed by 7 zeros (0), its final decimal value will be -128 (negative 128).
Q37.What will be the output of the following C code on a 64 bit machine?
#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}
a) 80
b) 15
c) 19
d) 4
Answer: d
Q38.What output will be the output of the following code in C?
#include <stdio.h>
enum birds {SPARROW, PEACOCK, PARROT};
enum pets {LION = 8, TIGER, ZEBRA, RABBIT};
int main()
{
enum birds m = LION;
int k;
k = m;
printf("%d\n", k);
return 0;
}
a) 0
b) Compile time error
c) 1
d) 8
Answer: d
Q39.Does the following code execute and what is the output?
#include <stdio.h>
int const print()
{
printf("Sanfoundry.com");
return 0;
}
void main()
{
print();
}
a) Error in program because function name cannot be come before or first by const
b) Sanfoundry.com
c) Sanfoundry.com is printed infinite times
d) Blank screen, no output
Answer: b
Q40.is there is any error in given code below or does it run without any error?
#include <stdio.h>
int main()
{
for(int x=0;x<10;x++);
return 0;
}
a) Yes
b) No
c) it depends on the standard implemented by Ccompilers
d) Error
Answer: c
Previous Topic:-->>Dynamic memory MCQ. || Next topic:-->>More MCQ in C.