You are on page 1of 6

QN=1 What will be the output of the following code?

#include <stdio.h>
int main(){
int w=3;
int x=31;
int y=10;
double z = x/y % w;
printf("%f\n",z);

return 0;
}
A. 1
B. 0
C. 0.1
D. 2
e.
f.
ANSWER: B
MARK: 1.0
UNIT: C – Logic
MIX CHOICES: Yes

QN=2 What will be the output of the following code?


For (cnt = 1; cnt <= 6 ; cnt++)
{
if (cnt == 5)
continue;
printf(“%d\t”,cnt);
}
A. 1 2 3 4 5
B. 1 2 3 4 6
C. Syntax Error
D. 1 2 3 4 6
e.
f.
ANSWER: D
MARK: 1.0
UNIT: C – Logic
MIX CHOICES: Yes

QN=3 What will be the output of the following code?

#include <stdio.h>
#include <conio.h>
int main()
{
int i = 0, j=0;
while (i<5, j<10)
{
i++;
j++;
}
printf("%d, %d\n", i,j);
getch();
}
a. 5, 5
b. Syntax Error
c. 10, 10
d. None of the above
e.
f.
ANSWER: C
MARK: 1.0
UNIT: C – Logic
MIX CHOICES: Yes

QN=4 What will be the output of the following code?

#include <stdio.h>
main(){
int i, ch;
for (int i=0, ch='A';i<5;i++,ch++)
putchar(ch);
}
a. ‘ABC’
b. ‘ACEG’
c. ‘ABCDE’
d. None of the above
e.
f.
ANSWER: C
MARK: 1.0
UNIT: G - Strings
MIX CHOICES: yes

QN=5 What will be the output of the program?


#include<stdio.h>
int f(int n, int k)
{
if (n == 0)
return 0;
else if (n % 2)
return f(n/2, 2*k) + k;
else return f(n/2, 2*k) - k;
}
int main ()
{
printf("%d", f(25, 1));
return 0;
}
a. 17
b. 18
c. 19
d. 20
e.
f.
ANSWER: C
MARK: 1.0
UNIT: D - Modularity and Functions
MIX CHOICES: Yes

QN=6 What will be the output of the program?

#include <stdio.h>
void f1 (int a, int b)
{
int c;
c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
int c;
c=*a; *a=*b;*b=c;
}
int main()
{
int a=4, b=5, c=6;
f1(a, b);
f2(&b, &c);
printf ("%d", c-a-b);
return 0;
}
a. -6
b. -5
c. -4
d. -3
e.
f.
ANSWER: B
MARK: 1.0
UNIT: E – Pointer
MIX CHOICES: Yes

QN=7 What will be the output of the program?

#include <stdio.h>
int main(){
int x = 65, *p = &x;
void *q=p;
char *r=q;
printf("%c",*r);
return 0;
}
a. Complie Error
b. A
c. 65
d. Runtime Error
e.
f.
ANSWER: B
MARK: 1.0
UNIT: E – Pointer
MIX CHOICES: Yes

QN=8 What will be the output of the program?

#include <stdio.h>
void f1 (int a, int b)
{
int c;
c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
int c;
c=*a; *a=*b;*b=c;
}
int main()
{
int a=4, b=5, c=6;
f1(a, b);
f2(&b, &c);
printf ("%d", c-a-b);
return 0;
}
a. -6
b. -5
c. -4
d. -3
e.
f.
ANSWER: B
MARK: 1.0
UNIT: E – Pointer
MIX CHOICES: Yes
QN=9 What will be the output of the program?

void main()
{
int ints[] = { 0, 5, 10, 15 };
int* i2 = ints + 2;
int a = *i2++; // a = *(i2++);
printf("%d#%d\n", a, *i2);
getch();
}
a. 10#15
b. 10#10
c. 15#15
d. 11#15
e.
f.
ANSWER: A
MARK: 1.0
UNIT: F – Array
MIX CHOICES: Yes

QN=10 What will be the output of the program?

#include <stdio.h>
#include <conio.h>

int main()
{
int array[2][2] = {0, 1, 2, 3};
int i;
int sum = 0;
for (i = 0; i<4; i++)
{
int x, y;
x = i % 2;
if (x)
{
y = 0;
}
else
{
y = 1;
}
sum += array[x][y];
}
printf("%d\n" , );
getch();
}
a. 4
b. 5
c. 6
d. 3
e.
f.
ANSWER: C
MARK: 1.0
UNIT: F – Array
MIX CHOICES: Yes

You might also like