1-
|
If a char is 1 byte wide, an integer is 2 bytes wide and a long integer is 4 bytes wide then will the following structure always occupy 7 bytes?
struct ex
{
char ch;
int i;
long int a;
};
|
|
A -
|
Yes
|
|
B -
|
No
|
2-
|
Point out the error/warning in the program?
#include<stdio.h>
int main()
{
unsigned char ch;
FILE *fp;
fp=fopen("trial", "r");
while((ch = getc(fp))!=EOF)
printf("%c", ch);
fclose(fp);
return 0;
}
|
|
A -
|
Error: in unsigned char declaration
|
|
B -
|
Error: while statement
|
|
C -
|
No error
|
|
D -
|
It prints all characters in file "trial"
|
3-
|
What will be the output of the program #include<stdio.h>
void fun(int);
int main(int argc)
{
printf("%d\n", argc);
fun(argc);
return 0;
}
void fun(int i)
{
if(i!=4)
main(++i);
}
|
|
A -
|
1 2 3
|
|
B -
|
1 2 3 4
|
|
C -
|
2 3 4
|
|
D -
|
1
|
4-
|
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
unsigned int num;
int i;
scanf("%u", &num);
for(i=0; i<16; i++)
{
printf("%d", (num<<i & 1<<15)?1:0);
}
return 0;
}
|
|
A -
|
It prints all even bits from num
|
|
B -
|
It prints all odd bits from num
|
|
C -
|
It prints binary equivalent num
|
|
D -
|
Error
|
5-
|
What will be the output of the program?
#include<stdio.h>
int fun(int **ptr);
int main()
{
int i=10;
const int *ptr = &i;
fun(&ptr);
return 0;
}
int fun(int **ptr)
{
int j = 223;
int *temp = &j;
printf("Before changing ptr = %5x\n", *ptr);
const *ptr = temp;
printf("After changing ptr = %5x\n", *ptr);
return 0;
}
|
|
A -
|
Address of i Address of j
|
|
B -
|
10 223
|
|
C -
|
Error: cannot convert parameter 1 from 'const int **' to 'int **'
|
|
D -
|
Garbage value
|
6-
|
Can I increase the size of dynamically allocated array?
|
|
A -
|
Yes
|
|
B -
|
No
|
7-
|
It is necessary to call the macro va_end if va_start is called in the function.
|
|
A -
|
Yes
|
|
B -
|
No
|
8-
|
What do the following declaration signify?
void (*cmp)();
|
|
A -
|
cmp is a pointer to an void function type.
|
|
B -
|
cmp is a void type pointer function.
|
|
C -
|
cmp is a function that return a void pointer.
|
|
D -
|
cmp is a pointer to a function which returns void .
|
9-
|
What will be the output of the program (in Turbo C under DOS)?
#include<stdio.h>
int main()
{
char huge *near *far *ptr1;
char near *far *huge *ptr2;
char far *huge *near *ptr3;
printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
return 0;
}
|
|
A -
|
4, 4, 8
|
|
B -
|
2, 4, 4
|
|
C -
|
4, 4, 2
|
|
D -
|
2, 4, 8
|
10-
|
What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *i = "55.555";
int result1 = 10;
float result2 = 11.111;
result1 = result1+atoi(i);
result2 = result2+atof(i);
printf("%d, %f", result1, result2);
return 0;
}
|
|
A -
|
55, 55.555
|
|
B -
|
66, 66.666600
|
|
C -
|
65, 66.666000
|
|
D -
|
55, 55
|