Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 27
1-
What will be the output of the program?
#include<stdio.h>
int main()
{
int arr[3] = {2, 3, 4};
char *p;
p = arr;
p = (char*)((int*)(p));
printf("%d, ", *p);
p = (int*)(p+1);
printf("%d", *p);
return 0;
}
A -
2, 3
B -
2, 0
C -
2, Garbage value
D -
0, 0
2-
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *str;
str = "%d\n";
str++;
str++;
printf(str-2, 300);
return 0;
}
A -
No output
B -
30
C -
3
D -
300
3-
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("%c\n", 7["IndiaBIX"]);
return 0;
}
A -
Error: in printf
B -
Nothing will print
C -
print "X" of IndiaBIX
D -
print "7"
4-
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str[] = "peace";
char *s = str;
printf("%s\n", s++ +3);
return 0;
}
A -
peace
B -
eace
C -
ace
D -
ce
5-
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *p;
p="hello";
printf("%s\n", *&*&p);
return 0;
}
A -
llo
B -
hello
C -
ello
D -
h
6-
What will be the output of the program assuming that the array begins at location 1002?
#include<stdio.h>
int main()
{
int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2},
{2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
printf("%u, %u, %u, %d\n", a, *a, **a, ***a);
return 0;
}
A -
1002, 2004, 4008, 2
B -
2004, 4008, 8016, 1
C -
1002, 1002, 1002, 1
D -
Error
7-
What will be the output of the program ?
#include<stdio.h>
power(int**);
int main()
{
int a=5, *aa; /* Address of 'a' is 1000 */
aa = &a;
a = power(&aa);
printf("%d\n", a);
return 0;
}
power(int **ptr)
{
int b;
b = **ptr***ptr;
return (b);
}
A -
5
B -
25
C -
125
D -
Garbage value
8-
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str1[] = "India";
char str2[] = "BIX";
char *s1 = str1, *s2=str2;
while(*s1++ = *s2++)
printf("%s", str1);
printf("\n");
return 0;
}
A -
IndiaBIX
B -
BndiaBIdiaBIXia
C -
India
D -
(null)
9-
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
int i, n;
char *x="Alice";
n = strlen(x);
*x = x[n];
for(i=0; i<=n; i++)
{
printf("%s ", x);
x++;
}
printf("\n", x);
return 0;
}
A -
Alice
B -
ecilA
C -
Alice lice ice ce e
D -
lice ice ce e
10-
What will be the output of the program ?
#include<stdio.h>
int main()
{
int i, a[] = {2, 4, 6, 8, 10};
change(a, 5);
for(i=0; i<=4; i++)
printf("%d, ", a[i]);
return 0;
}
void change(int *b, int n)
{
int i;
for(i=0; i<n; i++)
*(b+1) = *(b+i)+5;
}
A -
7, 9, 11, 13, 15
B -
2, 15, 6, 8, 10
C -
2 4 6 8 10
D -
3, 1, -1, -3, -5
[Người đăng: Thành Lãm - ST]