1-
|
What will be the output of the program if value 25 given to scanf()?
#include<stdio.h>
int main()
{
int i;
printf("%d\n", scanf("%d", &i));
return 0;
}
|
|
A -
|
25
|
|
B -
|
2
|
|
C -
|
1
|
|
D -
|
12
|
2-
|
Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned char;
FILE *fp;
fp=fopen("trial", "r");
if(!fp)
{
printf("Unable to open file");
exit(1);
}
fclose(fp);
return 0;
}
|
|
A -
|
Error: in unsigned char statement
|
|
B -
|
Error: unknown file pointer
|
|
C -
|
No error
|
|
D -
|
None of above
|
3-
|
What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%d %s", argc, argv[1]);
return 0;
}
|
|
A -
|
3 Good
|
|
B -
|
2 Good
|
|
C -
|
Good Morning
|
|
D -
|
3 Morning
|
4-
|
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[2] );
return 0;
}
|
|
A -
|
s
|
|
B -
|
j
|
|
C -
|
u
|
|
D -
|
r
|
5-
|
Even if integer/float arguments are supplied at command prompt they are treated as strings.
|
|
A -
|
True
|
|
B -
|
False
|
6-
|
If the different command line arguments are supplied at different times would the output of the following program change?
#include<stdio.h>
int main(int argc, char **argv)
{
printf("%d\n", argv[argc]);
return 0;
}
|
|
A -
|
Yes
|
|
B -
|
No
|
7-
|
What will be the output of the program?
#include<stdio.h>
typedef struct error {int warning, err, exception;} ERROR;
int main()
{
ERROR e;
e.err=1;
printf("%d\n", e.err);
return 0;
}
|
|
A -
|
0
|
|
B -
|
1
|
|
C -
|
2
|
|
D -
|
Error
|
8-
|
What will be the output of the program?
#include<stdio.h>
int main()
{
const int i=0;
printf("%d\n", i++);
return 0;
}
|
|
A -
|
10
|
|
B -
|
11
|
|
C -
|
No output
|
|
D -
|
Error: ++needs a value
|
9-
|
Which standard library function will you use to find the last occurance of a character in a string in C?
|
|
A -
|
strnchar()
|
|
B -
|
strchar()
|
|
C -
|
strrchar()
|
|
D -
|
strrchr()
|
10-
|
Data written into a file using fwrite() can be read back using fscanf()
|
|
A -
|
True
|
|
B -
|
False
|