1-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str1[] = "Hello";
char str2[10];
char *t, *s;
s = str1;
t = str2;
while(*t=*s)
*t++ = *s++;
printf("%s\n", str2);
return 0;
}
|
|
A -
|
Hello
|
|
B -
|
HelloHello
|
|
C -
|
No output
|
|
D -
|
ello
|
2-
|
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str = "IndiaBIX";
printf("%s\n", str);
return 0;
}
|
|
A -
|
IndiaBIX
|
|
B -
|
Error
|
|
C -
|
Base address of str
|
|
D -
|
No output
|
3-
|
If the size of pointer is 4 bytes then What will be the output of the program ?
#include<stdio.h>
int main()
{
char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
printf("%d, %d", sizeof(str), strlen(str[0]));
return 0;
}
|
|
A -
|
22, 4
|
|
B -
|
25, 5
|
|
C -
|
24, 5
|
|
D -
|
20, 2
|
4-
|
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
|
5-
|
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%c", *++argv[1]);
return 0;
}
|
|
A -
|
r
|
|
B -
|
f
|
|
C -
|
m
|
|
D -
|
y
|
6-
|
What will be the output of the program?
#include<stdio.h>
int main()
{
const int x=5;
const int *ptrx;
ptrx = &x;
*ptrx = 10;
printf("%d\n", x);
return 0;
}
|
|
A -
|
5
|
|
B -
|
10
|
|
C -
|
Error
|
|
D -
|
Garbage value
|
7-
|
Point out the error in the program (in Turbo-C).
#include<stdio.h>
#define MAX 128
int main()
{
const int max=128;
char array[max];
char string[MAX];
array[0] = string[0] = 'A';
printf("%c %c\n", array[0], string[0]);
return 0;
}
|
|
A -
|
Error: unknown max in declaration/Constant expression required
|
|
B -
|
Error: invalid array string
|
|
C -
|
None of above
|
|
D -
|
No error. It prints A A
|
8-
|
Point out the error in the program.
#include<stdio.h>
const char *fun();
int main()
{
char *ptr = fun();
return 0;
}
const char *fun()
{
return "Hello";
}
|
|
A -
|
Error: Lvalue required
|
|
B -
|
Error: cannot convert 'const char *' to 'char *'.
|
|
C -
|
No error and No output
|
|
D -
|
None of above
|
9-
|
Input/output function prototypes and macros are defined in which header file?
|
|
A -
|
conio.h
|
|
B -
|
stdlib.h
|
|
C -
|
stdio.h
|
|
D -
|
dos.h
|
10-
|
What will be the output of the program?
#include<stdio.h>
int main()
{
int i;
char c;
for(i=1; i<=5; i++)
{
scanf("%c", &c); /* given input is 'a' */
printf("%c", c);
ungetc(c, stdin);
}
return 0;
}
|
|
A -
|
aaaa
|
|
B -
|
aaaaa
|
|
C -
|
Garbage value.
|
|
D -
|
Error in ungetc statement.
|