Home
MCQS
C/C MCQ Quiz Hub
C Programming - MCQ Questions Set 1
Choose a topic to test your knowledge and improve your C/C skills
1. C99 standard guarantees uniqueness of __________ characters for internal names.
31
63
12
14
2. C99 standard guarantees uniqueness of ___________ characters for external names.
31
6
12
14
3. Which of the following is not a valid variable name declaration?
int __a3;
int __3a;
int __A3;
None of the mentioned
4. Which of the following is not a valid variable name declaration?
int _a3;
int a_3;
int 3_a;
int _3a
5. Why do variable names beginning with the underscore is not encouraged?
It is not standardized
To avoid conflicts since assemblers and loaders use such names
To avoid conflicts since library routines use such names
To avoid conflicts with environment variables of an operating system
6. All keywords in C are in _____
LowerCase letters
UpperCase letters
CamelCase letters
None of the mentioned
7. Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________
Compiler and linker implementations
Assemblers and loaders implementations
C language
None of the mentioned
8. Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int $main;
9. Which of the following is true for variable names in C?
They can contain alphanumeric characters as well as special characters
It is not an error to declare a variable to be one of the keywords(like goto, static)
Variable nam Variable names cannot start with a digites cannot start with a digit
Variable can be of any length
10. Which is valid C expression?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
11. Which of the following is not a valid variable name declaration?
float PI = 3.14;
double PI = 3.14;
int PI = 3.14;
#define PI 3.14
12. What is the problem in the following variable declaration? float 3Bedroom-Hall-Kitchen?;
The variable name begins with an integer
The special character ‘-‘
The special character ‘?’
All of the mentioned
13. Which of the following cannot be a variable name in C?
volatile
true
friend
export
14. The format identifier ‘%i’ is also used for _____ data type.
char
int
float
double
15. Which data type is most suitable for storing a number 65000 in a 32-bit system?
signed short
unsigned short
long
int
16. Which of the following is a User-defined data type?
typedef int Boolean;
typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
struct {char name[10], int age};
all of the mentioned
17. What is the size of an int data type?
4 Bytes
8 Bytes
Depends on the system/compiler
Cannot be determined
18. What is short int in C programming?
The basic data type of C
Qualifier
Short is the qualifier and int is the basic data type
All of the mentioned
19. Which is correct with respect to the size of the data types?
char > int > float
int > char > float
char < int < double
double > char > int
20. Which of the data types has the size that is variable?
int
struct
float
double
21. In the following code snippet, character pointer str holds a reference to the string ___________
Sanfoundry.com
Sanfoundry.com training classes
Sanfoundry.comtraining classes
Invalid declaration
22. enum types are processed by _________
Compiler
Preprocessor
Linker
Assembler
23. Which of the following statement is false?
Constant variables need not be defined as they are declared and can be defined later
Global constant variables are initialized to zero
const keyword is used to define constant values
You cannot reassign a value to a constant variable
24. Which of the following declaration is not supported by C?
String str;
char *str;
float str = 3e2;
Both String str; & float str = 3e2;
25. Which of the following declaration is illegal?
char *str = “Best C programming classes by Sanfoundry”;
char str[] = “Best C programming classes by Sanfoundry”;
char str[20] = “Best C programming classes by Sanfoundry”;
char[] str = “Best C programming classes by Sanfoundry”;
26. Which keyword is used to prevent any changes in the variable within a C program?
immutable
mutable
const
volatile
27. Which of the following is not a pointer declaration?
char a[10];
char a[] = {‘1’, ‘2’, ‘3’, ‘4’};
char *str;
char a;
28. Which of the following statement is false?
A variable defined once can be defined again with different scope
A single variable cannot be defined with two different types in the same scope
A variable must be declared and defined at the same time
A variable refers to a location in memory
29. A variable declared in a function can be used in main().
TRUE
FALSE
True if it is declared static
None of the mentioned
30. What is the precedence of arithmetic operators (from highest to lowest)?
%, *, /, +, –
%, +, /, *, –
+, -, %, *, /
%, +, -, *, /
31. Which of the following is not an arithmetic operation?
a * = 10;
a / = 10;
a ! = 10;
a % = 10;
32. Which of the following data type will throw an error on modulus operation(%)?
char
short
int
float
33. Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?
+, –
+, -, %
+, -, *, /
+, -, *, /, %
34. Are logical operator sequence points?
True
FALSE
Depends on the compiler
Depends on the standard
35. Do logical operators in the C language are evaluated with the short circuit?
True
FALSE
Depends on the compiler
Depends on the standard
36. What is the result of logical or relational expression in C?
True or False
0 or 1
0 if an expression is false and any positive number if an expression is true
None of the mentioned
37. Which among the following is NOT a logical or relational operator?
!=
==
||
=
38. Relational operators cannot be used on ________
structure
long
strings
float
39. function tolower(c) defined in library <ctype.h> works for ___________
Ascii character set
Unicode character set
Ascii and utf-8 but not EBCDIC character set
Any character set
40. Which type of conversion is NOT accepted?
From char to int
From float to char pointer
From negative int to char
From double to char
41. What will be the data type of the result of the following operation? (float)a * (int)b / (long)c * (double)d
int
long
float
double
42. Which of the following type-casting have chances for wrap around?
From int to float
From int to char
From char to short
From char to int
43. Which of the following typecasting is accepted by C?
Widening conversions
Narrowing conversions
Widening &amp; Narrowing conversions
None of the mentioned
44. When do you need to use type-conversions?
The value to be stored is beyond the max limit
The value to be stored is in a form not supported by that data type
To reduce the memory in use, relevant to the value
All of the mentioned
45. For which of the following, “PI++;” code will fail?
#define PI 3.14
char *PI = “A”;
float PI = 3.14;
none of the Mentioned
46. What will be the final values of a and c in the following C statement? (Initial values: a = 2, c = 1) c = (c) ? a = 0 : 2;
a = 0, c = 0;
a = 2, c = 2;
a = 2, c = 2;
a = 1, c = 2;
47. What will be the data type of the following expression? (Initial data type: a = int, var1 = double, var2 = float) expression (a < 50)? var1 : var2;
int
float
double
Cannot be determined
48. Which expression has to be present in the following? exp1 ? exp2 : exp3;
exp1
exp2
exp3
all of the mentioned
49. What will be the final value of c in the following C code snippet? (Initial values: a = 1, b = 2, c = 1) c += (-c) ? a : b;
Syntax Error
c = 1
c = 2
c = 3
50. What is the type of the following assignment expression if x is of type float and y is of type int? y = x + y;
int
float
there is no type for an assignment expression
double
Submit