C Language - Files

You Are Here :: Home > C Language > Files - General Questions

 
25.

What is the output of this C code?

#include
int main()
{
FILE *fp = stdin;
int n;
fprintf(fp, "%d", 45);
}

A. Compilation error B. 45
C. Nothing D. Depends on the standard




26.

What will be the output of the program ?

#include
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




27.

What will be the output of the program ?

#include
int main(){
++EOF;
printf("%d",EOF);
return 0;
}

A. 0 B. 1
C. -1 D. Compiler error




28.

What is the output of this C code?

#include
int main(){
char c;
FILE *fp;
fp=fopen("d:\\rootro~1\\shalu.txt","r");
while((c=fgetc(fp))!=EOF)
printf("%c",c);
fclose(fp);
return 0;
}

A. It will print contain of file D:/rootro/shalu.txt B. It will print contain of file D:/rootoot/shalu.txt
C. It will print contain of file D:/root root/shalu.txt D. It will print contain of file D:/root/shalu.txt




29.

What is the output of this code considering user typed jkl?

#include
int main()
{
char n[20];
fgets(n, 19, stdin);
ungetc(n[0], stdin);
printf("%s\n", n);
return 0;
}

A. jkl B. kl
C. Undefined behaviour D. jk




30.

What is the output of this C code?

#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 55);
fprintf(stderr, "%d ", 65);
return 0;
}

A. 55 65 B. 55 55
C. 65 D. Compilation error




« previous

1

2

3

4

5

6

7

next »

 
 
 



© 2013 freshersindia.in ® | Copyrights | Terms & Conditions
   Designed by Freshers India
Catch Us on