C Programming MCQ Questions | c interview questions

C Programming MCQ Questions | c interview questions

Introduction

In this article, you will find basic to most puzzled interview queries questions. This article is very useful for those who are preparing for an interview in IT company. Whether you are experienced or

techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999


11) What is the size of an int data type?
  1. 4 bytes
  2. 8 bytes
  3. 16 bytes
  4. 32 bytes

⇒ Answer: (A) 4 bytes

12) Which of the following is a User-defined data type?
  1. struct {char name[10], int age};
  2. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
  3. typedef int Boolean;
  4. all of the mentioned

⇒ Answer: (D) all of the mentioned.

13) What is 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. }
  1. -128
  2. 128
  3. Depends on the compiler
  4. None of the mentioned

⇒ Answer: (B) -128, Since signed char will be a negative number.

14) What will be the output of the following C code?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a[5] = {1, 2, 3, 4, 5};
  5. int i;
  6. for (i = 0; i < 5; i++)
  7. if ((char)a[i] == '5')
  8. printf("%d successful\n", a[i]);
  9. else
  10. printf("Unsuccessful\n");
  11. }
  12.  
  1. The compiler will flag an error
  2. The program will compile and print the output 5
  3. It is not an error to declare a variable to be one of the keywords(like goto, static)
  4. The program will compile and print Unsuccessful for 5 times.

⇒ Answer: (D) The program will compile and print Unsuccessful for 5 times.

15) The format identifier ‘%i’ is also used for which data type in C?
  1. double
  2. float
  3. char
  4. int

⇒ Answer: (D) int

     

16) Which is correct with respect to the size of the data types?
  1. double > char > int
  2. char < int < double
  3. int > char > float
  4. char > int > float

⇒ Answer: (B) char < int < double

17) Which of the data types has the size that is variable in C?
  1. double
  2. float
  3. struct
  4. int

⇒ Answer: (C) struct

18) What will be the output of the following C code?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. float num1 = 0.1;
  5. if (num1 == 0.1)
  6. printf("equal\n");
  7. else
  8. printf("not equal\n");
  9. }
  10.  
  1. not equal
  2. equal
  3. output depends on the compiler
  4. none of the mentioned

⇒ Answer: (A) not equal.

19) What will be the output of the following C code on a 32-bit machine?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a = 5000;
  5. double b = 56;
  6. int *c = &a;
  7. double *d = &b;
  8. printf("c and d are %d and %d", sizeof(c), sizeof(d));
  9. return 0;
  10. }
  11.  
  1. c and d are 2 and 8
  2. compiler time error
  3. c and d are 4 and 8
  4. c and d are 4 and 4

⇒ Answer: (D) c and d are 4 and 4

20) What will be the output of the following C code?

  1. #include <stdio.h>
  2. int main()
  3. {
  4. float a = 'a';
  5. printf("%f", a);
  6. return 0;
  7. }
  8.  
  1. 97.000000
  2. a.0000000
  3. run time error
  4. a

⇒ Answer: (A) 97.000000

« 1 2 3 4 5

Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers. http://www.techstudy.org/.