0% found this document useful (0 votes)
188 views4 pages

Sample MID Exam Questions

The document contains 10 multiple choice questions about C programming concepts. It tests knowledge of code snippets involving variables, data types, operators, conditional statements, switch statements, header files, comments, and identifiers. The correct answers are provided for each question.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views4 pages

Sample MID Exam Questions

The document contains 10 multiple choice questions about C programming concepts. It tests knowledge of code snippets involving variables, data types, operators, conditional statements, switch statements, header files, comments, and identifiers. The correct answers are provided for each question.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Find the output of the below code segment?

float interest = 0.0;


float bal = 10000.00;
char type = ‘F’;

if (type == ‘A’)
interest = bal * 0.25;

bal = bal + interest + bal * 0.1;


printf(“%.2f\n”, bal);

Select one:
a. 0.00
b. 1000.00
c. 3500.00
d. 13500.00
e. 11000.00

The correct answer is: 11000.00

2. Consider the below C structure which represents the groups in an institute. studentCount represents the no
of students in a given group.
struct group
{
int groupNo;
int studentCount;
}group1, group2;

There are 115 students in group1 and 123 students in group2. Which of the following C statements will correctly
assign these student counts?

Select one:
a. group. studentCount = 115; group. studentCount = 123;
b. group1. studentCount = 115; group2. studentCount = 123;
c. studentCount = 115; studentCount = 123;
d. group1 = 115; group2 = 123;
e. int studentCount1 = 115; int studentCount2 = 123;

The correct answer is: group1. studentCount = 115; group2. studentCount = 123;

3. Which of the following X value will yield the below expression to ‘True’?
( X < (X + 1) ) && (X == 8)

Select one:
a. 10
b. Any integer
c. 1
d. 8
e. None of the above

The correct answer is: 8


4. If the value of X is 1245, what is the output of the below statement?
printf(“%d-%d-%d-%d\n”, X % 1000 % 100 % 10, X % 1000 % 100 / 10, X % 1000 / 100, X / 1000);

Select one:
a. 1-2-4-5
b. 5-4-2-1
c. 1000-100-10-1
d. 1-10-100-1000
e. None of the above

The correct answer is: 5-4-2-1

5. Which of the following are correct identifiers?

Select one:
a. total , 1num , average_mark , _total
b. total salary , average , num1
c. totalMark , salary , num_one , average
d. int , num , salary , total
e. mark , total , average , $count

The correct answer is: totalMark , salary , num_one , average

6. Choose the correct statement/statements ?

Select one or more:


a. A program can be compiled and executed without the header file <stdio.h>
b. <stdio.h> is a header file with predefined functions like printf, scanf etc

c. A C compiler translates the source code into object code line by line.

d. A program can be compiled and executed without a main function.

e. #include is a Preprocessor Directive

The correct answers are:

<stdio.h> is a header file with predefined functions like printf, scanf etc,

A program can be compiled and executed without the header file <stdio.h>

#include is a PreprocessorDirective

7. Select the correct statement/s from the following.

Select one or more:


a. comments are executable
b. comments improve the readability of the program
c. Comment can have any character
d. Comments are case sensitive
e. Always the comment should start with a // or /*
The correct answers are:
comments improve the readability of the program
Always the comment shouldstart with a // or /*,
Comment can have any character

8. What will be the output of following code segment?

int sum = 15;

if ( sum <= 20 )
sum = sum + 5;
else
sum = sum - 5;

sum = sum + 15;


printf("value = %d \n" , sum);

Select one:
a. value = 30
b. value = 15
c. value = 20
d. value = 10
e. value = 35

The correct answer is: value = 35

9. What will be the output of following code segment?


int choice = 2 ;
switch(choice)
{
case 1+2 / 3:
printf("First\n");
break;
case 2 / 2 * 3:
printf("Second\n");
break;
default:
printf("Error\n");
}
Select one:
a. First
b. Error
c. No output
d. Second
e. FirstSecond

The correct answer is: Error


10. We can store _____ within following variable.

char letter;

Select one:
a. Alphabetical characters and numeric values only
b. Any character
c. Lowercase alphabetical characters only
d. Numeric values only
e. Uppercase and lowercase alphabetical characters only

The correct answer is: Any character

You might also like