1 CP MCQ's With Solutions 2022
1 CP MCQ's With Solutions 2022
1 CP MCQ's With Solutions 2022
============================================================================
==============================================================================
Choose the correct option for following questions. All the Questions are
Q1.
compulsory and carry equal marks
1. Which storage class is called as default storage class ?
Option A: auto : The auto storage class is the default storage class for all local variables.
Option B: register
Option C: static
Option D: extern
2. What inbuilt function should be used to return a value rounded up to the next higher
integer ?
Option A: floor
Option B: malloc
Option C: puts
Option D: ceil : This function returns nearest integer value which is greater than or
equal to the argument passed to this function.
Option A: i=0
Option B: i=10
Option C: i=110
Option D: i=1
By Prof Yogesh
5. How many times will the following while-loop repeat, i.e., how many x are printed?
int main()
{
int i = 5;
while(i> 0)
{
printf(“x”);
i--;
}
return 0;
}
Option A: 2
By Prof Yogesh
Option B: 3
Option C: 4
Option D: 5 XXXXX (x=5,4,3,2,1,0(loop will stop))
10 C programs are converted into machine language with the help of -------- --.
Option A: an editor
Option B: an Assembler
Option C: A compiler : A compiler is a program that convert a source program written in
high-level programming language such as C, Java in to machine language.
Option D: an operating system
By Prof Yogesh
13 What is the output of the C statement.?
int main()
{
int a=0;
a = 5<2 ? 4 : 3;
//5<2 is false (0) hence false part of ?: will run hence 3 assigned to a
printf("%d",a);
return 0;
}
Option A: 4
Option B: 3
Option C: 5
Option D: 2
By Prof Yogesh
/* Operators : 3)=,2)++(postfix),1)+
1) a+b is 2
2)a++ means a=a+1=1+1=2
3)c=2
a=1,b=1(unchanged),c=2*/
Option A: a=1, b=1
Option B: a=2, b=1
Option C: a=2, b=2
Option D: a=1, b=2
By Prof Yogesh
#include <stdio.h>
void main()
{
int x = 5;
if (x == 5)
printf("hi\n");
else
printf("how are u\n");
printf("hello\n");
}
int main()
{
int x=5;
//clrscr();
if (x==5)
printf("hi\n");
else
printf("how are u\n");
printf("hello\n");
//getch();
return 0;
}
Option A: hi
Option B: hi
hello
Option C: how are you
hello
Option D: how are you
20 What will be the output of the following C code? (Assuming that we have entered
the value 1 in the standard input).
#include <stdio.h>
void main()
{
int ch;
printf("enter a value between 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
break;
printf("hi");
default:
printf("2\n");
}
}
Option A: 1
By Prof Yogesh
Option B: 1
hi
Option C: hi
Option D: 2
#include <stdio.h>
int main()
{
int i = 0;
while (i = 0)
printf("True\n");
printf("False\n");
}
int main()
{
int i=0;
//clrscr();
while(i=0)
printf("True\n");
printf("False\n");
//getch();
return 0;
}
Option A: True
Option B: False
Option C: True
False
Option D: True (Infinite Times)
By Prof Yogesh
22 What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x= 0;
if (x= =1)
if (x= =0)
printf("inside if\n");
else
printf("inside else if\n");
else
printf("inside else\n");
}
Option A: inside if
inside else
Option B: inside else if
Option C: inside if
Option D: inside else
23 The value obtained in the function is given back to the main program by using
which keyword?
Option A: new
Option B: return
Option C: volatile
Option D: static
The static storage class instructs the compiler to keep a local variable in
existence during the life-time of the program instead of creating and
destroying it each time it comes into and goes out of scope. Therefore,
making local variables static allows them to maintain their values between
function calls
Option A: 55
Option B: 56
Option C: 66
Option D: 67
By Prof Yogesh
25 An array Index starts with.?
Option A: 0
Option B: 1
Option C: -1
Option D: 2
By Prof Yogesh
char string[]={'E','X','A','M','\0'};
printf("%s",string);
}
Option A: E
Option B: EXAM0
Option C: EXAM\0
Option D: EXAM
Option B: c_program
Option C: 20cprogram
Option D: cprogram20
while(10<9) -- false */
Option A: 9
Option B: 10
Option C: 1
Option D: 11
Option A: 10
Option B: 9
Option C: 8
Option D: 20
By Prof Yogesh
30 If a is a variable initialized to 1, how many times will the following loop be executed?
while((a>0)&&(a<25))
{
loopbody
a++;
}
#include<stdio.h>
//#include<conio.h>
int main()
{
int a=1;
//clrscr();
while((a>0)&&(a<25))
{
//loop body
a++;
}
//getch();
return 0;
}
Option A: 25
Option B: 24
Option C: 20
Option D: 26
By Prof Yogesh
Option B: 20
Option C: 30
Option D: 40
#include<stdio.h>
int main()
{
int a=500,b=100,c;
if(!a>=400)
b = 300;
else
b=b+++b*a/b;
c=10;
c=b<<1;
c=c>>b+1;
return 0;
}
B=600, c=3
Option B: B=600, c=2
Option C: B=600, c=1
Option D: B=600, c=0
33 Which bitwise operator is used for turning off a particular bit in a number?
Option A: |
Option B: ^
Option C: &
Option D: ~
By Prof Yogesh
34 What will be the output of the following
program?int i;
int
goodday();
int main()
{
while(i)
{
main();
goodday()
;i++;
}
printf("Exam\n
");return 0;
}
int goodday()
{
printf("Goodday");
}
#include<stdio.h>
//#include<conio.h>
int main()
{
while(i) //while(0) means false hence while loop will never run
{
main();
goodday();
i++;
}
printf("Exam\n");
//getch();
return 0;
} //end of main()
int goodday()
{
printf("Goodday");
}
Option A: Goodday
Option B: Exam Goodday
By Prof Yogesh
Option C: Exam
Option D: Goodday Exam
By Prof Yogesh
By Prof Yogesh
By Prof Yogesh