C Programming - Practice Quiz Paper with answers
Correct
Sl No. Question Option-1 Option-2 Option-3 Option-4 answer
What is the output of the following
program?
main()
{
1 if(0.55 == 0.55f)
printf("I am here");
else
printf("I don't think that I am here"); I don't think that I Error in the
} I am here am here comparison Can’t say depends 2
2 Which bitwise operator is suitable for
turning off a particular bit in a number? &&operator &operator ||operator !operator 2
If an unsigned int is 2 bytes wide then,
what will be the output of the program?
#include<stdio.h>
int main()
3 {
unsigned int a=0xffff;
~a;
printf("%x\n", a);
return 0;
} ffff 0000 00ff ddfd 1
What will be the output of the program
in 32 bit machine?
#include<stdio.h>
double i;
4 int main()
{
(int)(float)(char) i;
printf("%d",sizeof(i));
return 0;
} 4 8 16 22 2
5 _______ sends formatted output to a
string pointed. scanf( ) sscanf( ) sprintf( ) Sget( ) 3
________ function accepts a string
6 representation of an integer, and returns
its integer equivalent Itoa atoi Convert All of the above 2
What is the output of the following
program?
#include <stdio.h>
int main()
{
7 int x = 0x11223344;
int i;
i = sizeof(x=0x5566);
printf("%x %x", i, x);
return 0;
} 4 11223344 4 5566 2 5566 compilation error 1
8 Which is not a token? Identifiers Keywords Constants functions 4
9 Dangling pointer is Pointer pointing Name defined as Pointer initialized to Pointer that
_____________________ to No-Where NULL unknown address returned 0 value 1
What is problem in the below code?
main(){ break cannot be
10 int x=0; used without x++ statement No, there is no error
if(x++) break; loop or switch cannot be used in if in the mentioned None from the
} statements condition code options 1
What is the output of the following code?
main(){
int a=1;
switch(a){
11 case 1: printf(“hello”);
case 2: printf(“world”);
break;
default:
printf(“What”);
}
} hello helloworld helloworldWhat What 2
number of
12 When you pass an array as an argument elements of the value of elements address of the first value of the first
to a function, what actually gets passed? array of the array element element 3
What is the output of the following code
13 snippet? name =
char name[5] = {'n', 'a', 'm', 'e'}; name = followed by name followed by
printf ("name = \n%s", name); name = name junk characters some garbage chas None of the above 3
14 array of integer pointer to an
int *a[5] refers to pointers integer array pointer to a pointer None of the above 1
What is the ouput?
main(){
15 int arr[]={1,2,3,4,5};
printf(“%d”, -2[arr]);
} 5 -5 -3 Gargage value 3
Predict the output of the following
int main() {
int a[10]={10,20,30,40,50};
int *ptr=a;
16
*ptr+=2;
printf(“%d\n”,*ptr);
printf(“%d”,*ptr);
} 30 30 12 12 12 30 10 20 2
What is the output of the following code?
int main(){
17 char str[]=“Hello\0”;
printf(“Len:%d”,strlen(str));
} Len:6 Len:5 Len:4 compile error 2
Question: To access the 6th element of
the array which of the following is
incorrect?
18 Description:
int a[50];
int *pa;
pa = a; *(a+5) a[5] pa[5] *(*pa + 5) 4
What is the output of the following
program?
main()
{
19
int num = 1025, num2=255;
num &=num2;
printf("num is %d\n",num);
} 0 1 512 256 2
What is the output of the following code
snippet?
void func( char * );
int main()
{
char *p = “Hello World” ;
func (p);
20
puts (p);
}
void func(char * p)
{
p=(char *)malloc(100);
strcpy(p, “Hi There” );
} Hello World Hi There Hi World Hello There 1
What will be the value of count, when
func(6) is called ?
int func(int x)
{
int count=0,i;
for(i=0;i<x;i++)
21 {
if((i%2)==0)
continue;
count++;
}
return count;
} 6 2 3 1 3
struct point
{
int x;
int y;
};
struct point origin,*pp;
22 main()
{
pp=&origin;
printf("origin
is(%d%d)\n",(*pp).x,(*pp).y);
printf("origin is (%d%d)\n",pp->x,pp->y); Garbage values for origin is(0,0) does not print
} error both origin is(0,0) anything 3
What is the output of the program?
int func(int x) {
int a=4;
return(x=x+2, x+1);
}
23 int x=10;
int main() {
int x=8;
x = func(x);
printf("%d", x);
} 13 9 12 11 4
What is the output of the program?
int i = 1;
int num[] = {1,2,3,4};
24
i << 1;
num[i] = i + 1;
printf("%d", num[i]); 4 3 2 1 3
fun (int x) {
if(x > 0)
fun(x / 4);
25 printf("%d", x);
}
Above function is invoked as: fun(20);
what will it print? 01520 015 0 1520 1