C Programming MCQs with answers Page - 9

Here, you will find a collection of MCQ questions on C Programming. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. Which of the following typecasting is accepted by C?

  • (A) conversions
  • (B) Widening conversions
  • (C) Narrowing conversions
  • (D) Widening & Narrowing conversions

A

Admin • 833K Points
Coach

Q. Which of the following type-casting have chances for wrap around?

  • (A) From char to int
  • (B) From char to short
  • (C) From int to float
  • (D) From int to char

A

Admin • 833K Points
Coach

Q. What will be the data type of the result of the following operation?

  • (A) double
  • (B) float
  • (C) long
  • (D) int

A

Admin • 833K Points
Coach

Q. Which type of conversion is NOT accepted?

  • (A) From double to char
  • (B) From negative int to char
  • (C) From char to int
  • (D) From float to char pointer

A

Admin • 833K Points
Coach

Q. What will be the output of the following C code considering the size of short int is 2, char is 1 and int is 4 bytes?

Code:
#include <stdio.h>
    int main()
    {
        short int k = 23;
        char ch = 99;
        printf("%d, %d, %d
", sizeof(k), sizeof(ch), sizeof(ch + k));
        return 0;
    }
  • (A) 23
  • (B) 99
  • (C) 2, 1, 4
  • (D) 4, 1, 2

A

Admin • 833K Points
Coach

Q. function tolower(c) defined in library <ctype.h> works for

  • (A) Unicode character set
  • (B) Ascii and utf-8 but not EBCDIC character set
  • (C) Ascii character set
  • (D) Any character set

A

Admin • 833K Points
Coach

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

Code:
#include <stdio.h>
    int main()
    {
        int n = 25;
        char ch = -25;
        if (n < ch)
        {
            printf("Yes
");
        }
        else
        {
            printf("No
");
        }
    }
  • (A) 25
  • (B) Yes
  • (C) No
  • (D) Depends on the compiler

A

Admin • 833K Points
Coach

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

Code:
#include <stdio.h>
    int main()
    {
        unsigned int n = 25;
        signed char ch = -25;
        if (n > ch)
        {
            printf("Yes
");
        }
        else if (n < ch)
        {
            printf("No
");
        }
    }
  • (A) Yes
  • (B) No
  • (C) Depends on the compiler
  • (D) Depends on the compiler

A

Admin • 833K Points
Coach

Q. When double is converted to float, then the value is?

  • (A) Depends on the compiler
  • (B) Depends on the standard
  • (C) Truncated
  • (D) Rounded

A

Admin • 833K Points
Coach

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

Code:
#include <stdio.h>
    void main()
    {
        int n = 98;
        char m = n;
        printf("%c
", m);
    }
  • (A) 98
  • (B) Compilation error
  • (C) b
  • (D) Garbage value