100% found this document useful (1 vote)
190 views12 pages

C Programming Output Scenarios

c programming mcqs

Uploaded by

Sanskriti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
190 views12 pages

C Programming Output Scenarios

c programming mcqs

Uploaded by

Sanskriti Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Each question below gives a multiple choices of answers.

Choose the most


appropriate one.

1. Best known solution amongst available solution for given situation is


called as a) Heuristics algorithm
b) Easy Solution
c) Proposed Algorithm
d)All of these
Correct Answer:a) Heuristics algorithm

2. Which statement correctly reads an integer value from the user in C?


a) scanf("%d", &number);
b) print("%d", &number);
c) input("%d", number);
d) read("%d", number);
Correct Answer:a) scanf("%d", &number);
3. Errors in C coding are
A) Syntax Errors
B) Semantic Errors
C) Syntax and Semantic Errors
D) None of these

Correct Answer: C) Syntax and Semantic Errors

4. C programs are converted into machine language with the help of

A) An Editor

B) A compiler
C) An operating system
D) None of the above

Correct Answer: A) An Editor

5. Stages of Problem Solving include


a) Problem Understanding b) Planning Strategy
c) Implementation and testing d) All of these

Correct Answer: d) All of these

6. The C statement printf (“The Value =%x”,62); will print

a) The Value= 62

b) The Value = O62

c) The Value= OX 3C

d) The Value= 3C

Correct Answer:d) The Value= 3C


7. What is the purpose of the #define directive in C?
A)To create a variable
B) To define a constant
C) To include libraries
D) To declare functions

Correct Answer: B) To define a constant

8. What is the correct way to declare a variable of type float in C?


A) float variable_name;

B) float: variable_name;

C) float variable_name

D) variable_name float;

Correct Answer: A) float variable_name;

9. In C coding, an integer literal can be named as

a) int 10Num1 b) int Num10 c) float 10Num2 d) all of these

Correct Answer: b) int Num10

10.What will the following C code output?


int x = 5; printf("%d", x++);
A) 5
B) 6
C) Undefined
D) 0

Correct Answer:A) 5

11.If a is an integer variable, a = 5 / 2 ; will return a value


(1) 2.5
(2) 3
(3) 2
(4) 0
Correct Answer:(3) 2
12.Which of the following is a valid declaration of a constant?

A) const int x = 10;


B) int const x;
C) constant int x = 10;
D) int x = const 10;
Correct Answer:A) const int x = 10;

13.What will be the output of the following code snippet?

int main() {

int x = 10;

int y = x++;

printf("%d %d", x, y);

return 0;

a) 10 10

b) 11 10

c) 10 11

d) 11 11

Correct Answer: b) 11 10

14.Consider the following C Program .


# define S 10+2
#include <stdio.h>
int main() { /* begin main */
int Result = S + S ;
printf (“\n\n Result = %d\n\n”, Result ); /* Output Line #2 */
return (0);
} /* end main*/
15.The Output generated by the above C Program will be
a) Result = 10 b) Result = 12
c) Result = 24 d) Result = 20
Correct Answer: c) Result = 24
16.Which of the following statements correctly declares a variable in C?
A) int 1a;
B) float value;
C) char @char;
D) double total*;

Correct Answer:B) float value;


17.What will be the output of the following C code snippet?
#include <stdio.h>
int main() {
int a = 10; int b = 20; int c;
c = (a > b) ? a : b;
printf("The maximum value is: %d\n", c);
return 0; }
A) The maximum value is: 10
B) The maximum value is: 20
C) The maximum value is: 0
D) The program will not compile

Correct Answer:B) The maximum value is: 20

18.In C coding “%s” represents formatting

a) Integers b)Real Numbers c) Strings d) None of these

Correct Answer:c) Strings

19.In C, what will the following code snippet output: printf("%d", 10/3);?

a) 3.3333
b) 3

c) 3.0

d) 10/3

Correct Answer: b) 3

20.What will be the output of the following code snippet?


#include <stdio.h>
int main() {
int x = 5;
int y = ++x * 2;
printf("%d\n", y);
return 0; }
A) 10
B) 12
C) 14
D) 8

Correct Answer:B) 12

21. main( )
{
float a = 5, b = 2 ;
int c ;
c=a%b;
printf ( "%d", c ) ;
}
A) 1
B) 5
C) 14
D) 82

Correct Answer:B) 5

22.In a flowchart, what does a diamond shape represent?


A) Start/End
B) Process
C) Decision
D) Input/Output

Correct Answer: C) Decision


main( ) {
int a, b ;
printf ( "Enter values of a and b" ) ;
scanf ( " %d %d ", &a, &b ) ;
printf ( "a = %d b = %d", a, b ) ;
}

A) a = 5 b = 20
B) a = 20 b = 10
C) a = 5 b = 12
D)a = 52 b = 10

Correct Answer:B) a = 20 b = 10

23. int main() {

printf(“%d”, 10 + 20 * 30);

return 0;

}
A) 600

B) 620

C) 610

D) 700

Correct Answer:C) 610

24. The C declaration int I_a; implies

a) The variable I_a is a signed Binary Integer .

b) The variable I_a is an Unsigned Decimal Integer.

c) The variable I_a is an signed Hexadecimal Integer.

d) The variable I_a is a signed Integer that can be expressed in any Base.

Correct Answer:a) The variable I_a is a signed Binary Integer .

25. What will be the output of the following code snippet?

#include<stdio.h>

int main()

int a = 5;

int b = 10;

printf("%d", a + b);

return 0;

a) 15

b) 510
c) 5+10

d) Compilation Error

Correct Answer:a) 15

26. A character variable can at a time store


A) 1 character
B) 8 characters
C) 254 characters
D) None of the above
Correct Answer:A) 1 character
27. How does an interpreter differ from a compiler in terms of error handling
during execution?
a) An interpreter detects and reports errors at runtime, while a compiler detects all
errors at compile time
b) An interpreter reports errors after execution is complete, whereas a compiler
reports errors during execution
c) An interpreter does not handle errors, while a compiler handles errors at runtime
d) Both an interpreter and a compiler handle errors in the same way
Correct Answer:a) An interpreter detects and reports errors at runtime, while a
compiler detects all errors at compile time

28. Which of the following format specifiers is used for printing a character?

A) %s

B) %d

C) %c

D) %f
Correct Answer:C) %c

29.The programming Language C happens to be

a) An Assembly Level Language.

b) A High Level Language with some Assembly Level Language Features.

c) A Programming Language used only to write System Software.

d) A Programming Language used for developing Application Packages only.

Correct Answer: b) A High Level Language with some Assembly Level Language
Features.

30. What will be the Output generated by the following C Program ?

#include <stdio.h>

int main()

{ /* begin main */

int I_C ; float F_D , F_E;

I_C = 5/2 ; F_D = 5/2 ; F_E = 5/2.0;

printf (“\n I_C = %d F_D =%f F_E = %f \n\n”, I_C,F_D,F_E);

return (0);

} /* end main*/

a) I_C= 1 F D = 2.0 F_E = 2.5 b) I_C= 2 F D = 2.0 F_E = 2.5

c) I_C= 2 F D = 2.5 F_E = 2.0 d) I_C= 2 F D = 2.5 F_E = 2.5

Correct Answer:b) I_C= 2 F D = 2.0 F_E = 2.5

31. What is the result of the following code snippet?


#include <stdio.h>

int main() {

int x = 0;

int y = 1;

int z = x++ || ++y;

printf("%d %d %d", x, y, z);

return 0;

A) 1 2 1

B) 1 1 1

C) 1 2 0

D) 0 1 0

Correct Answer:A) 1 2 1

32. What is the purpose of setting goals when solving a problem?

A) To create unnecessary stress

B) To clarify what you want to achieve

C) To limit your options

D) To avoid taking action

Correct Answer:B) To clarify what you want to achieve

33. What is a common use of flowcharts in software development?

a) Writing source code for a program

b) Designing and documenting algorithms visually

c) Compiling and executing programs


d) Debugging and testing code

Correct Answer: b) Designing and documenting algorithms visually

34.Which of the following statements about the sizeof operator in C is true?

a) sizeof can be used to determine the size of variables and data types at runtime

b) sizeof is a runtime operator that returns the size of a variable in bytes

c) sizeof returns the size of the variable or type in bytes, determined at compile
time

d) sizeof can only be used with variables, not with data type

Correct Answer: c) sizeof returns the size of the variable or type in bytes,
determined at compile time

35. What is the result of the following code snippet when compiled and run?

#include <stdio.h>

int main() {

int a = 7, b = 2;

printf("%d %d\n", a & b, a | b);

return 0;

a) 2 7

b) 1 7

c) 2 6

d) 0 7

Correct Answer:a) 2 7

You might also like