Cprogramming Mock Test II
Cprogramming Mock Test II
This sect ion present s you various set of Mock Test s relat ed t o C Pro gramming Framewo rk. You
can download t hese sample mock t est s at your local machine and solve offline at your convenience.
Every mock t est is supplied wit h a mock t est key t o let you verify t he final score and grade yourself.
A - Object code
C - Assembly code
D - None of t he above.
B - Object code
C - Assembly code
D - None of t he above.
A-$
B- @
C-_
D- .
A-;
B- :
C - /*
D - //
A - t rue
B - false
A - Int
B - volat ile
C - DOUBLE
D - __0__
#include<stdio.h>
main()
{
int *p, **q;
printf("%u\n", sizeof(p));
printf("%u\n", sizeof(q));
}
D - Error in t he code.
Q 8 - What is the built in library functio n to adjust the allo cated dynamic memo ry
size.
A - malloc
B - calloc
C - realloc
D - resize
A - gcc
B - cc
C - Borland
D - vc++
Q 10 - Fo llo wing is the invalid inclusio n o f a file to the current pro gram. Identify it.
A - #include <file>
B - #include file
#include<stdio.h>
int* f()
{
int x = 5;
return &x;
}
main()
{
printf("%d", *f());
}
A-5
B - Address of x
C - Compile error
#include<stdio.h>
main()
{
char *p = NULL;
printf("%c", *p);
}
A - NULL
B- 0
C - Compile error
B- a
C - a.out
D - out .a
#include<stdio.h>
void f()
{
static int i = 3;
A - 321 0
B- 321
C - 333
D - Compile error
#include<stdio.h>
main()
{
}
A - No out put
B - Garbage
C - Compile error
Q 16 - Cho o se the co rrect o ptio n in respect to the fo llo wing pro gram.
#include<stdio.h>
C - St at ement I is t rue
D - St at ement II is t rue.
A - t rue
B - false
#include<stdio.h>
int x = 5;
int* f()
{
return &x;
}
main()
{
*f() = 10;
printf("%d", x);
}
A - Compile error
C-5
D - 10
#include<stdio.h>
main()
{
printf("%d", -11%2);
}
A-1
B - -1
C - 5.5
D - -5.5
#include<stdio.h>
main()
{
printf("\\ri\\ng \\the \\bells");
}
A - \ri\ng \t he \bells
B- i
g heells
C-i
he \bells
D - None of t he above
Q 21 - Do es bo th the lo o ps in the fo llo wing pro grams prints the co rrect string
length?
#include<stdio.h>
main()
{
int i;
char s[] = "hello";
i=0;
while(s[i++]);
printf("%d ", i);
}
#define PI 3.141
A - It s float
B - It s double
A - __FILE__
B - __DATE__
C - __TIME__
D - __C++__
#include<stdio.h>
main()
{
int a[] = {10, 20, 30};
printf("%d", *a+1);
}
A - 10
B - 20
C - 11
D - 21
#include<stdio.h>
f(a);
for(i=0; i<3; ++i)
{
printf("%d ",a[i]);
}
}
A - 10 20 30
B - 11 21 31
C - Compile error
#include<stdio.h>
main()
{
char *s = "Hello, "
"World!";
printf("%s", s);
}
A - Hello, World!
B - Hello,
Wo rld!
C - Hello
D - Compile error
#include<stdio.h>
main()
{
fprintf(stdout,"Hello, World!");
}
A - Hello, World!
B - No out put
C - Compile error
#include<stdio.h>
main()
{
fprintf(stdout,"Hello, World!");
}
A - Hello, World!
B - No out put
C - Compile error
Q 29 - Which o f the fo llo wing is used in mo de string to o pen the file in binary
mo de?
A-a
B- b
C-B
D - bin
#include<stdio.h>
main()
{
char s[] = "Fine";
*s = 'N';
printf("%s", s);
}
A - Fine
B - Nine
C - Compile error
#include<stdio.h>
main()
{
char *s = "Fine";
*s = 'N';
printf("%s", s);
}
A - Fine
B - Nine
C - Compile error
#include<stdio.h>
main()
{
int x;
float y;
y = x = 7.5;
printf("x=%d y=%f", x, y);
}
A - 7 7.000000
B - 7 7.500000
C - 5 7.500000
D - 5 5.000000
A - st ring_cmp()
B - st rcmp()
C - equals()
D - st r_compare()
#include<stdio.h>
main()
{
char s1[50], s2[50] = "Hello";
s1 = s2;
printf("%s", s1);
}
A - Hello
B - No out put
C - Compile error
#include<stdio.h>
int main();
void main()
{
printf("Okay");
}
A - Okay
B - No out put
#include<stdio.h>
void main()
{
char *s = "C++";
A - C++ C++
B - C++ ++
C - ++ ++
D - Compile error
#include<stdio.h>
void main()
{
char s[] = "C++";
printf("%s ",s);
s++;
printf("%s",s);
}
A - C++ C++
B - C++ ++
C - ++ ++
D - Compile error
A - Code segment
B - St ack segment
C - Heap segment
D - None of t he above
#include<stdio.h>
main()
{
printf("%d", -1<<1 );
}
A-2
B - -2
C-1
D - -1
#include<stdio.h>
main()
{
int x = 3;
x += 2;
x =+ 2;
printf("%d", x);
}
A-2
B- 5
C-7
D - Compile error
#include<stdio.h>
main()
{
char *s = "Abc";
while(*s)
printf("%c", *s++);
}
A - Abc
B - bc
C - Compile error
#include<stdio.h>
main()
{
char s[20] = "Hello\0Hi";
printf("%d %d", strlen(s), sizeof(s));
}
A-59
B - 7 20
C - 5 20
D - 8 20
#include<stdio.h>
main()
{
char s[] = "Hello\0Hi";
A-59
B - 7 20
C - 5 20
D - 8 20
#include<stdio.h>
main()
{
printf("%d", !0<2);
}
A-0
B- 1
C - False
D - True
#include<stdio.h>
main()
{
struct student
{
int num = 10;
}var;
printf("%d", var.num);
}
A - 10
B - Garbage
D - Compile error
#include<stdio.h>
A - 9 16
B- 97
D - None of t he above.
#include<stdio.h>
main()
{
char *s = "Hello";
while(*s!=NULL)
printf("%c", *s++);
}
A - Hello
B - Helloellolloloo
C - ello
D - Compile error
#include<stdio.h>
main()
{
#undef NULL
char *s = "Hello";
while(*s != NULL)
{
printf("%c", *s++);
}
}
A - Hello
A - C++
B - B++
C-B
D - Mini C
Q 50 - Which o f the fo llo wing functio ns disco nnects the stream fro m the file
po inter.
A - fremove()
B - fclose()
C - remove()
ANSWER SHEET
1 B
2 B
3 C
4 D
5 A
6 B
7 A
8 C
9 B
10 C
11 D
12 D
13 C
14 B
15 A
16 D
17 B
18 D
19 B
20 A
21 B
22 C
23 D
24 C
25 B
26 A
27 C
28 A
29 B
30 B
31 D
32 A
33 B
34 C
35 D
36 B
37 D
38 B
39 B
40 A
41 A
42 C
43 A
44 B
45 D
46 B
47 A
48 D
49 C
50 B