Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 17
1-
What will be the output of the program?
#include<stdio.h>
int main()
{
int fun(int);
int i = fun(10);
printf("%d\n", --i);
return 0;
}
int fun(int i)
{
return (i++);
}
A -
9
B -
10
C -
11
D -
8
2-
What will be the output of the program?
#include<stdio.h>
int check (int, int);
int main()
{
int c;
c = check(10, 20);
printf("c=%d\n", c);
return 0;
}
int check(int i, int j)
{
int *p, *q;
p=&i;
q=&j;
i>=45 ? return(*p): return(*q);
}
A -
Print 10
B -
Print 20
C -
Print 1
D -
Compile error
3-
What will be the output of the program?
#include<stdio.h>
int fun(int, int);
typedef int (*pf) (int, int);
int proc(pf, int, int);
int main()
{
printf("%d\n", proc(fun, 6, 6));
return 0;
}
int fun(int a, int b)
{
return (a==b);
}
int proc(pf p, int a, int b)
{
return ((*p)(a, b));
}
A -
6
B -
1
C -
-1
D -
-6
4-
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=1;
if(!i)
printf("IndiaBIX,");
else
{
i=0;
printf("C-Program");
main();
}
return 0;
}
A -
prints "IndiaBIX, C-Program" infinitely
B -
prints "C-Program" infinetly
C -
prints "C-Program, IndiaBIX" infinitely
D -
Error: main() should not inside else statement
5-
What will be the output of the program?
#include<stdio.h>
int addmult(int ii, int jj)
{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}
int main()
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d %d\n", k, l);
return 0;
}
A -
12 12
B -
No error, No output
C -
Error: Compile error
D -
None of above
6-
What will be the output of the program?
#include<stdio.h>
int i;
int fun1(int);
int fun2(int);
int main()
{
extern int j;
int i=3;
fun1(i);
printf("%d,", i);
fun2(i);
printf("%d", i);
return 0;
}
int fun1(int j)
{
printf("%d,", ++j);
return 0;
}
int fun2(int i)
{
printf("%d,", ++i);
return 0;
}
int j=1;
A -
3, 4, 4, 3
B -
4, 3, 4, 3
C -
3, 3, 4, 4
D -
3, 4, 3, 4
7-
What will be the output of the program?
#include<stdio.h>
int func1(int);
int main()
{
int k=35;
k = func1(k=func1(k=func1(k)));
printf("k=%d\n", k);
return 0;
}
int func1(int k)
{
k++;
return k;
}
A -
k=35
B -
k=36
C -
k=37
D -
k=38
8-
What will be the output of the program?
#include<stdio.h>
int addmult(int ii, int jj)
{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}
int main()
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d, %d\n", k, l);
return 0;
}
A -
12, 12
B -
7, 7
C -
7, 12
D -
12, 7
9-
What will be the output of the program?
#include<stdio.h>
int check(int);
int main()
{
int i=45, c;
c = check(i);
printf("%d\n", c);
return 0;
}
int check(int ch)
{
if(ch >= 45)
return 100;
else
return 10;
}
A -
100
B -
10
C -
1
D -
0
10-
If int is 2 bytes wide.What will be the output of the program?