Professional Documents
Culture Documents
a. Compiler error
b. False value 0
True value 1
c. False value 0
True value 0
d. False value 1
True value 1
a. Compiler error
b. hello followed by junk characters
c. hello
d. h
3. How to declare a function pointer that returns void and takes the following two parameters?
1) an integer variable
2) a pointer to function that returns void
void main()
{
printf("%d, %d",func(&i),i);
}
a. 7, 7
b. 7, 0
c. Garbage Value
d. 4, 4
a. ANSI C notation
b. Kernighan & Ritche notation
c. CamelCase notation
d. None of these
a. Runtime error
b. 1
c. 0
d. Compiler error
7. What will be the output of the following program?
void main()
{
int i=12;
printf("%d\n",printf("%d",printf("%d",i)));
}
a. 1234
b. 1221
c. 12
d. Compiler error
a. 12
b. Compiler error
c. 22
d. 21
a. Runtime error
b. 2 2 2 2 2 2 3 4 6 6
c. 2 2 2 2 2 2 3 4 6 5
d. Compiler error
a. Redefinition error
b. 3 3 3
c. 3 2 1 0
d. 3 2 1
13. What will be the output of the following program?
#include<stdio.h>
int main()
{
int a[][3] = { 1,2,3 ,4,5,6};
int (*ptr)[3] =a;
printf("%d %d ",(*ptr)[1],(*ptr)[2]);
++ptr;
printf("%d %d ",(*ptr)[1],(*ptr)[2]);
return 0;
}
a. 1 2 4 5
b. Compiler error
c. 5 6 0 0
d. 2 3 5 6
14. What will be the output of the following program if MyFile.txt contains Clue[EOF]Less[\n][space]Life[\n]?
#include<stdio.h>
int main()
{
char buff[80];
FILE* fp=fopen("MyFile.txt", "w");
if(!fgets(buff, 80, fp))
return 1;
printf("buff= %s\n", buff);
return 0;
}
a. Clue
b. Clue[EOF]Less[\n][space]Life[\n]
c. buff will be empty
d. Program will crash
a. Good Morning
b. Morning
c. M
d. Good
16. Consider following program. Assume that source file contains a statement “To err is human”.
#include <stdio.h>
int main( )
{
int i, fss ;
char ch, source[20] = "source.txt", target[20] = "target.txt", t ;
FILE *fs, *ft ;
fs = fopen ( source, "r" ) ;
ft = fopen ( target, "w" ) ;
while ( 1 )
{
ch = getc ( fs ) ;
if ( ch == EOF )
break ;
else
{
fseek ( fs, 4L, SEEK_CUR ) ;
fputc ( ch, ft ) ;
}
}
return 0;
}
What would be the contents of target.txt file?
a. r n
b. Trh
c. Err
d. None of these
a. 1 2 3
223
b. 1 0 1
102
c. 0 0 0
011
d. 0 1 1
111