Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 69
1-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str[] = "Nagpur";
str[0]='K';
printf("%s, ", str);
str = "Kanpur";
printf("%s", str+1);
return 0;
}
|
|
A -
|
Kagpur, Kanpur
|
|
B -
|
Nagpur, Kanpur
|
|
C -
|
Kagpur, anpur
|
|
D -
|
Error
|
2-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
int i=4, j=8;
printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j);
return 0;
}
|
|
A -
|
12, 12, 12
|
|
B -
|
112, 1, 12
|
|
C -
|
32, 1, 12
|
|
D -
|
-64, 1, 12
|
3-
|
Bit fields CANNOT be used in union.
|
|
A -
|
True
|
|
B -
|
False
|
4-
|
Which of the following statement is correct about the program?
#include<stdio.h>
int main()
{
FILE *fp;
char ch;
int i=1;
fp = fopen("myfile.c", "r");
while((ch=getc(fp))!=EOF)
{
if(ch == '\n')
i++;
}
fclose(fp);
return 0;
}
|
|
A -
|
The code counts number of characters in the file
|
|
B -
|
The code counts number of words in the file
|
|
C -
|
The code counts number of blank lines in the file
|
|
D -
|
The code counts number of lines in the file
|
5-
|
The first argument to be supplied at command-line must always be count of total arguments.
|
|
A -
|
True
|
|
B -
|
False
|
6-
|
What will be the output of the program?
#include<stdio.h>
int main()
{
char c=48;
int i, mask=01;
for(i=1; i<=5; i++)
{
printf("%c", c|mask);
mask = mask<<1;
}
return 0;
}
|
|
A -
|
12480
|
|
B -
|
12400
|
|
C -
|
12500
|
|
D -
|
12556
|
7-
|
What is the output of the program?
typedef struct data;
{
int x;
sdata *b;
}sdata;
|
|
A -
|
Error: Declaration missing ';'
|
|
B -
|
Error: in typedef
|
|
C -
|
No error
|
|
D -
|
None of above
|
8-
|
Which header file should you include, if you are going to develop a function, which can accept variable number of arguments?
|
|
A -
|
varagrg.h
|
|
B -
|
stdlib.h
|
|
C -
|
stdio.h
|
|
D -
|
stdarg.h
|
9-
|
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...);
int main()
{
varfun(3, 7, -11.2, 0.66);
return 0;
}
void varfun(int n, ...)
{
float *ptr;
int num;
va_start(ptr, n);
num = va_arg(ptr, int);
printf("%d", num);
}
|
|
A -
|
Error: too many parameters
|
|
B -
|
Error: invalid access to list member
|
|
C -
|
Error: ptr must be type of va_list
|
|
D -
|
No error
|
10-
|
va_list is an array that holds information needed by va_arg and va_end
|
|
A -
|
True
|
|
B -
|
False
|
[Người đăng: Thành Lãm - ST]
|