C Programming

Q 1. Who is the father of C language?
A. Steve Jobs
B. Dennis Ritchie
C. James Gosling
D. Rasmus Lerdorf

Show Answer Answer:-B. Dennis Ritchie
Explanation Dennis Ritchie is the father of C Programming Language. C programming language was developed in 1972 at American Telephone & Telegraph Bell Laboratories of USA.

Q 2. Which of the following is not a valid C variable name?
A. int $main;
B. float rate;
C. int variable_count;
D. int number;

Show Answer Answer:-A. int $main;
Explanation Since only underscore and no other special character is allowed in a variable name, it results in an error.

Q 3.Which of the following is true for variable names in C?
A. Variable names cannot start with a digit
B. It is not an error to declare a variable to be one of the keywords(like goto, static)
C. They can contain alphanumeric characters as well as special characters
D. Variable can be of any length

Show Answer Answer:-A. Variable names cannot start with a digit
Explanation According to the syntax for C variable name, it cannot start with a digit

Q 4.Which is valid C expression?
A. int my_num = 100,000;
B. int $my_num = 10000;
C. int my num = 1000;
D. int my_num = 100000;

Show Answer Answer:-D. int my_num = 100000;
Explanation Space, comma and $ cannot be used in a variable name

Q 5. Which of the following cannot be a variable name in C?
A. volatile
B. true
C. friend
D. export

Show Answer Answer:-A. volatile
Explanation volatile is C keyword.

Q 6.What will be the output of the following C code?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int y = 10000;
  5. int y = 34;
  6. printf(“Hello World! %d\n“, y);
  7. return 0;
  8. }

A. Compile time error
B. Hello World! 34
C. Hello World! 1000
D. Hello World! followed by a junk value

Show Answer Answer:-A. Compile time error
Explanation Since y is already defined, redefining it results in an error. Output: $ cc pgm2.c pgm2.c: In function ‘main’: pgm2.c:5: error: redefinition of ‘y’ pgm2.c:4: note: previous definition of ‘y’ was here

Q 7.What will be the output of the following C code?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. signed char chr;
  5. chr = 128;
  6. printf(“%d\n“, chr);
  7. return 0;
  8. }

A. 128
B. -128
C. Depends on the compiler
D. None of the mentioned

Show Answer Answer:- B. -128
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). Output: $ cc pgm2.c $ a.out -128

Q 8.Which of the following declaration is not supported by C language?
A. String str;
B. char *str;
C. float str = 3e2;
D. Both “String str;” and “float str = 3e2;”

Show Answer Answer:-A. String str;
Explanation It is legal in Java, but not in C language.

Q 9. Which keyword is used to prevent any changes in the variable within a C program?
A. const
B. mutable
C. immutable
D. volatile

Show Answer Answer:-A. const
Explanation const is a keyword constant in C program.

Q 10.What is the sizeof(char) in a 32-bit C compiler?
A. 1 bit
B. 2 bits
C.1 Byte
D. 2 Bytes

Show Answer Answer:-C.1 Byte
Explanation None.

Q 11.What will happen if the following C code is executed?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int main = 3;
  5. printf(“%d”, main);
  6. return 0;
  7. }

A. It will cause a compile-time error
B. It will cause a run-time error
C. It will run without any error and prints 3
D. It will experience infinite looping

Show Answer Answer:-C. It will run without any error and prints 3
Explanation A C program can have same function name and same variable name. $ cc pgm3.c $ a.out 3

Q 12.Property which allows to produce different executable for different platforms in C is called?
A. File inclusion
B. Selective inclusion
C. Conditional compilation
D. Recursive macros

Show Answer Answer:- C. Conditional compilation
Explanation Conditional compilation is the preprocessor facility to produce a different executable.

Q 13.scanf() is a predefined function in______header file.

A. stdlib. h
B. ctype. h
C. stdio. h
D. stdarg. h

Show Answer Answer:-C. stdio. h
Explanation scanf() is a predefined function in “stdio.h” header file.printf and scanf() carry out input and output functions in C. These functions statements are present in the header file stdio.h.

Q 14. C preprocessors can have compiler specific features.
A. True
B. False
C. Depends on the standard
D. Depends on the platform

Show Answer Answer:- A. True
Explanation #pragma is compiler specific feature.

Q 15.The C-preprocessors are specified with _________ symbol.
A. #
B. $
C. ” ”
D. &

Show Answer Answer:-A. #
Explanation The C-preprocessors are specified with # symbol.

Q 16.How is search done in #include and #include “somelibrary.h” according to C standard?
A. When former is used, standard directory is searched and when latter is used, current directory is searched
B. When former is used, current directory is searched and when latter is used, standard 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 for ‘somelibrary’ is done in implementation-defined places

Show Answer Answer:-A. When former is used, standard directory is searched and when latter is used, current directory is searched

Q 17. How many number of pointer (*) does C have against a pointer variable declaration?
A. 7
B. 127
C. 255
D. No limits

Show Answer Answer:-D. No limits

Q 18 .Which of the following is not possible statically in C language?
A. Cuboidal Array
B. Rectangular Array
C. Jagged Array
D. Multidimensional Array

Show Answer Answer:- C. Jagged Array

Q 19.Which of the following return-type cannot be used for a function in C?
A. char *
B. struct
C. void
D. none of the mentioned

Show Answer Answer:-D. none of the mentioned

Q 20. The standard header _______ is used for variable list arguments (…) in C.
A. <stdio.h >
B. <stdarg.h>
C. <math.h>
D. <stdlib.h>

Show Answer Answer:- B.

Q 21.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

Show Answer Answer:-D. All of the mentioned

Q 22.In C language, FILE is of which data type?
A. int
B. char *
C. struct
D. None of the mentioned

Show Answer Answer:-C. struct

Q 23.What is meant by ‘a’ in the following C operation?

fp = fopen("Random.txt", "a");

A. Attach
B. Append
C. Apprehend
D. Add

Show Answer Answer:- B. Append

Q 24. What is short int in C programming?
A. The basic data type of C
B. Short is the qualifier and int is the basic data type
C. Qualifier
D. All of the mentioned

Show Answer Answer:-B. Short is the qualifier and int is the basic data type

Q 25.What is the result of logical or relational expression in C?
A. True or False
B. 0 or 1
C. 0 if an expression is false and any positive number if an expression is true
D. None of the mentioned

Show Answer Answer:-B. 0 or 1

Q 26.Which of the following is not an operator in C?
A. ,
B. sizeof()
C. ~
D. None of the mentioned

Show Answer Answer:-D. None of the mentioned

Q 27. All keywords in C are in ____________
A. CamelCase letters
B. UpperCase letters
C. LowerCase letters
D. None of the mentioned

Show Answer Answer:-C. LowerCase letters

Q 28. Which of the following are C preprocessors?
A. #ifdef
B. #define
C. #endif
D. all of the mentioned

Show Answer Answer:-D. all of the mentioned

Q 29.What is #include <stdio.h>?
A. File inclusion directive
B. Inclusion directive
C. Preprocessor directive
D. None of the mentioned

Show Answer Answer:-C. Preprocessor directive

Q 30.Where in C the order of precedence of operators do not exist?
A. Within conditional statements, if, else
B. Within while, do-while
C. Within a macro definition
D. None of the mentioned

Show Answer Answer:-D. None of the mentioned

Q 31 .Which of the following is NOT possible with any 2 operators in C?
A. Different precedence, same associativity
B. Same precedence, different associativity
C. Different precedence, different associativity
D. All of the mentioned

Show Answer Answer:-B. Same precedence, different associativity

Q 32.What is an example of iteration in C?
A. for
B. while
C. do-while
D. all of the mentioned

Show Answer Answer:- D. all of the mentioned

Q 33.Functions can return enumeration constants in C?
A. true
B. false
C. depends on the compiler
D. depends on the standard

Show Answer Answer:-A. true

Q 34.Which of following is not accepted in C?
A. static static int a; //a static variable prefixed with static
B. static int func (int); //parameter as static
C. static a = 10; //static as
D. all of the mentioned

Show Answer Answer:-A. static static int a; //a static variable prefixed with static

Q 35. Which of the following typecasting is accepted by C language?
A. Widening & Narrowing conversions
B. Narrowing conversions
C.Widening conversions
D. None of the mentioned

Show Answer Answer:-A. Widening & Narrowing conversions

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page