1-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *fp;
unsigned char ch;
/* file 'abc.c' contains "This is IndiaBIX " */
fp=fopen("abc.c", "r");
if(fp == NULL)
{
printf("Unable to open file");
exit(1);
}
while((ch=getc(fp)) != EOF)
printf("%c", ch);
fclose(fp);
printf("\n", ch);
return 0;
}
|
|
A -
|
This is IndiaBIX
|
|
B -
|
This is
|
|
C -
|
Infinite loop
|
|
D -
|
Error
|
2-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2, 23);
return 0;
}
|
|
A -
|
21
|
|
B -
|
23
|
|
C -
|
Error
|
|
D -
|
No output
|
3-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *ptr;
char i;
ptr = fopen("myfile.c", "r");
while((i=fgetc(ptr))!=NULL)
printf("%c", i);
return 0;
}
|
|
A -
|
Print the contents of file "myfile.c"
|
|
B -
|
Print the contents of file "myfile.c" upto NULL character
|
|
C -
|
Infinite loop
|
|
D -
|
Error in program
|
4-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("%%%%\n");
return 0;
}
|
|
A -
|
%%%%%
|
|
B -
|
%%
|
|
C -
|
No output
|
|
D -
|
Error
|
5-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
int a=250;
printf("%1d\n", a);
return 0;
}
|
|
A -
|
1250
|
|
B -
|
2
|
|
C -
|
50
|
|
D -
|
250
|
6-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *fp;
char ch, str[7];
fp=fopen("try.c", "r"); /* file 'try.c' contains "This is Nagpur" */
fseek(fp, 9L, SEEK_CUR);
fgets(str, 5, fp);
puts(str);
return 0;
}
|
|
A -
|
agpur
|
|
B -
|
gpur
|
|
C -
|
Nagp
|
|
D -
|
agpu
|
7-
|
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 -
|
5
|
8-
|
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
|
9-
|
Point out the error in the program?
#include<stdio.h>
int main()
{
char ch;
int i;
scanf("%c", &i);
scanf("%d", &ch);
printf("%c %d", ch, i);
return 0;
}
|
|
A -
|
Error: suspicious char to in conversion in scanf()
|
|
B -
|
Error: we may not get input for second scanf() statement
|
|
C -
|
No error
|
|
D -
|
None of above
|
10-
|
Point out the error in the program?
#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("trial", "r");
fseek(fp, "20", SEEK_SET);
fclose(fp);
return 0;
}
|
|
A -
|
Error: unrecognised Keyword SEEK_SET
|
|
B -
|
Error: fseek() long offset value
|
|
C -
|
No error
|
|
D -
|
None of above
|