C/C /C Programming - MCQ Questions Set 1 Sample Test,Sample questions

Question:
A variable declared in a function can be used in main().

1.TRUE

2.FALSE

3. True if it is declared static

4.None of the mentioned


Question:
All keywords in C are in _____

1.LowerCase letters

2. UpperCase letters

3. CamelCase letters

4.None of the mentioned


Question:
Are logical operator sequence points?

1. True

2.FALSE

3.Depends on the compiler

4.Depends on the standard


Question:
 Which of the following declaration is illegal?

1.char *str = “Best C programming classes by Sanfoundry”;

2.char str[] = “Best C programming classes by Sanfoundry”;

3.char str[20] = “Best C programming classes by Sanfoundry”;

4.char[] str = “Best C programming classes by Sanfoundry”;


Question:
 Which of the following is a User-defined data type?

1.typedef int Boolean;

2.typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;

3.struct {char name[10], int age};

4.all of the mentioned


Question:
 Which of the following is not an arithmetic operation?

1.a * = 10;

2.a / = 10;

3. a ! = 10;

4.a % = 10;


Question:
C99 standard guarantees uniqueness of ___________ characters for external names.

1.31

2.6

3.12

4.14


Question:
Do logical operators in the C language are evaluated with the short circuit?

1. True

2.FALSE

3.Depends on the compiler

4.Depends on the standard


Question:
enum types are processed by _________

1.Compiler

2.Preprocessor

3.Linker

4.Assembler


Question:
For which of the following, “PI++;” code will fail?

1.#define PI 3.14

2.char *PI = “A”;

3.float PI = 3.14;

4.none of the Mentioned


Question:
function tolower(c) defined in library <ctype.h> works for ___________

1.Ascii character set

2.Unicode character set

3.Ascii and utf-8 but not EBCDIC character set

4.Any character set


Question:
In the following code snippet, character pointer str holds a reference to the string ___________

1.Sanfoundry.com

2. Sanfoundry.comtraining classes

3.Sanfoundry.comtraining classes

4. Invalid declaration


Question:
C99 standard guarantees uniqueness of __________ characters for internal names.

1.31

2.63

3.12

4.14


Question:
Relational operators cannot be used on ________

1.structure

2.long

3.strings

4. float


Question:
The format identifier ‘%i’ is also used for _____ data type.

1.char

2. int

3.float

4.double


Question:
Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________

1.Compiler and linker implementations

2. Assemblers and loaders implementations

3.C language

4.None of the mentioned


Question:
What is short int in C programming?

1.The basic data type of C

2.Qualifier

3.Short is the qualifier and int is the basic data type

4.All of the mentioned


Question:
What is the precedence of arithmetic operators (from highest to lowest)?

1.%, *, /, +, –

2.%, +, /, *, –

3.+, -, %, *, /

4.%, +, -, *, /


Question:
What is the problem in the following variable declaration?  float 3Bedroom-Hall-Kitchen?;

1.The variable name begins with an integer

2.The special character ‘-‘

3.The special character ‘?’

4.All of the mentioned


Question:
What is the result of logical or relational expression in C?

1.True or False

2.0 or 1

3. 0 if an expression is false and any positive number if an expression is true

4.None of the mentioned


Question:
What is the size of an int data type?

1.4 Bytes

2.8 Bytes

3. Depends on the system/compiler

4.Cannot be determined


Question:
What is the type of the following assignment expression  if x is of type float and y is of type int? y = x + y;

1.int

2. float

3.there is no type for an assignment expression

4.double


Question:
What will be the data type of the following expression? (Initial data type: a = int, var1 = double, var2 = float) expression (a < 50)? var1 : var2;

1. int

2.float

3.double

4. Cannot be determined


Question:
What will be the data type of the result of the following operation? (float)a * (int)b / (long)c * (double)d

1.int

2.long

3. float

4. double


Question:
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;

1.Syntax Error

2. c = 1

3. c = 2

4.c = 3


Question:
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;

1.a = 0, c = 0;

2.a = 2, c = 2;

3.a = 2, c = 2;

4.a = 1, c = 2;


Question:
When do you need to use type-conversions?

1.The value to be stored is beyond the max limit

2.The value to be stored is in a form not supported by that data type

3.To reduce the memory in use, relevant to the value

4.All of the mentioned


Question:
Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?

1. +, –

2.+, -, %

3.+, -, *, /

4.+, -, *, /, %


Question:
Which among the following is NOT a logical or relational operator?

1. !=

2.==

3.||

4. =


Question:
Which data type is most suitable for storing a number 65000 in a 32-bit system?

1.signed short

2.unsigned short

3.long

4. int


Question:
Which expression has to be present in the following?   exp1 ? exp2 : exp3;

1.exp1

2.exp2

3.exp3

4.all of the mentioned


Question:
Which is correct with respect to the size of the data types?

1.char > int > float

2.int > char > float

3.char < int < double

4.double > char > int


Question:
Which is valid C expression?

1.int my_num = 100,000;

2. int my_num = 100000;

3.int my num = 1000;

4.int $my_num = 10000;


Question:
Which keyword is used to prevent any changes in the variable within a C program?

1.immutable

2.mutable

3.const

4.volatile


Question:
Which of the data types has the size that is variable?

1.int

2.struct

3.float

4.double


Question:
Which of the following cannot be a variable name in C?

1.volatile

2. true

3.friend

4. export


Question:
Which of the following data type will throw an error on modulus operation(%)?

1.char

2.short

3.int

4.float


Question:
Which of the following declaration is not supported by C?

1.String str;

2.char *str;

3.float str = 3e2;

4.Both String str; & float str = 3e2;


Question:
Which of the following is not a pointer declaration?

1.char a[10];

2.char a[] = {‘1’, ‘2’, ‘3’, ‘4’};

3.char *str;

4.char a;


Question:
Which of the following is not a valid C variable name?

1.int number;

2.float rate;

3.int variable_count;

4.int $main;


Question:
Which of the following is not a valid variable name declaration?

1.int __a3;

2.int __3a;

3. int __A3;

4.None of the mentioned


Question:
Which of the following is not a valid variable name declaration?

1.int _a3;

2.int a_3;

3.int 3_a;

4.int _3a


Question:
Which of the following is not a valid variable name declaration?

1.float PI = 3.14;

2. double PI = 3.14;

3.int PI = 3.14;

4.#define PI 3.14


Question:
Which of the following is true for variable names in C?

1.They can contain alphanumeric characters as well as special characters

2.It is not an error to declare a variable to be one of the keywords(like goto, static)

3. Variable nam Variable names cannot start with a digites cannot start with a digit

4.Variable can be of any length


Question:
Which of the following statement is false?

1.Constant variables need not be defined as they are declared and can be defined later

2.Global constant variables are initialized to zero

3. const keyword is used to define constant values

4. You cannot reassign a value to a constant variable


Question:
Which of the following statement is false?

1.A variable defined once can be defined again with different scope

2.A single variable cannot be defined with two different types in the same scope

3. A variable must be declared and defined at the same time

4. A variable refers to a location in memory


Question:
Which of the following type-casting have chances for wrap around?

1.From int to float

2.From int to char

3. From char to short

4.From char to int


Question:
Which of the following typecasting is accepted by C?

1.Widening conversions

2.Narrowing conversions

3.Widening & Narrowing conversions

4.None of the mentioned


Question:
Which type of conversion is NOT accepted?

1.From char to int

2. From float to char pointer

3.From negative int to char

4.From double to char


Question:
Why do variable names beginning with the underscore is not encouraged?

1.It is not standardized

2. To avoid conflicts since assemblers and loaders use such names

3.To avoid conflicts since library routines use such names

4.To avoid conflicts with environment variables of an operating system


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!