Que.1. Which of the following is correct about err used in the declaration given below?
typedef enum error { warning, test, exception
} err;
A: It is a typedef for enum error.
B: It is a variable of type enum error.
C: The statement is erroneous.
D: It is a structure.
Right Answer : A
Que.2. Point out
the error in the following program.
#include<stdio.h>
int main()
{
void v = 0;
printf("%d", v);
return 0;
}
A: Error: Declaration syntax error 'v' (or)
Size of v is unknown or zero.
B: Program terminates abnormally.
C: No error.
D: None of these.
Right Answer : A
Que.3. What will be
the output of the program?
#include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}
A: 40 40
B: 20 40
C: 20
D: Error
Right Answer : B
Que.4. Point out
the error in the following program.
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
emp int xx;
int a;
printf("%d\n", &a);
return 0;
}
A: Error: in printf
B: Error: in emp int xx;
C: No error.
D: None of these.
Right Answer : B
Que.5. What will be
the output of the program?
#include<stdio.h>
void fun(int*,
int*);
int main()
{
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *i,
int *j)
{
*i = *i**i;
*j = *j**j;
}
A: 5, 2
B: 25, 4
C: 10, 4
D: 2, 5
Right Answer : B
Que.6. What is the
output of the program?
#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d, %d, %d\n", u.ch[0],
u.ch[1], u.i);
return 0;
}
A: 3, 2, 515
B: 515, 2, 3
C: 3, 2, 5
D: None of these
Right Answer : A
Que.7. Point out
the error in the following program (if it is compiled with Turbo C compiler).
#include<stdio.h>
int main()
{
display();
return 0;
}
void display()
{
printf("iExamCenter.com");
}
A: No error
B: display() doesn't get invoked
C: display() is called before it is
defined
D: None of these
Right Answer : C
Que.8. Which of the
following statement is correct prototype of the malloc() function in c ?
A: int* malloc(int);
B: char* malloc(char);
C: unsigned int* malloc(unsigned int);
D: void* malloc(size_t);
Right Answer : D
Que.9. Point out
the correct statement will let you access the elements of the array using 'p'
in the following program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i, j;
int(*p)[3];
p = (int(*)[3])malloc(3*sizeof(*p));
return 0;
}
A: for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
printf("%d", p[i+j]);
}
B: for(i=0; i<3; i++)
printf("%d", p[i]);
C: for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
printf("%d", p[i][j]);
}
D: for(j=0; j<3; j++)
printf("%d", p[i][j]);
Right Answer : C
Que.10. In the
following program how long will the for loop get executed?
#include<stdio.h>
int main()
{
int i=5;
for(;scanf("%s", &i);
printf("%d\n", i));
return 0;
}
A: The for loop would not get executed at
all
B: The for loop would get executed only
once
C: The for loop would get executed 5 times
D: The for loop would get executed infinite
times
Right Answer : D
Que.11. What is the
output of the program in Turbo C (in DOS 16-bit OS)?
#include<stdio.h>
int main()
{
char *s1;
char far *s2;
char huge *s3;
printf("%d, %d, %d\n",
sizeof(s1), sizeof(s2), sizeof(s3));
return 0;
}
A: 2, 4, 6
B: 4, 4, 2
C: 2, 4, 4
D: 2, 2, 2
Right Answer : C
Que.12. What is the
output of the program
#include<stdio.h>
int main()
{
int x = 10, y = 20, z = 5, i;
i = x < y < z;
printf("%d\n", i);
return 0;
}
A: 0
B: 1
C: Error
D: None of these
Right Answer : B
Que.13. What is the
output of the program
#include<stdio.h>
int main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("%d, %f\n", e.age, e.sal);
return 0;
}
A: 0, 0.000000
B: Garbage values
C: Error
D: None of above
Right Answer : A
Que.14. Point out
the correct statement which correctly allocates memory dynamically for 2D array
following program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *p, i, j;
/* Add statement here */
for(i=0; i<3; i++)
{
for(j=0; j<4; j++)
{
p[i*4+j] = i;
printf("%d", p[i*4+j]);
}
}
return 0;
}
A: p = (int*) malloc(3, 4);
B: p = (int*) malloc(3*sizeof(int));
C: p = malloc(3*4*sizeof(int));
D: p = (int*) malloc(3*4*sizeof(int));
Right Answer : D
Que.15. What is the
output of the program
#include<stdio.h>
int main()
{
extern int fun(float);
int a;
a = fun(3.14);
printf("%d\n", a);
return 0;
}
int fun(int aa)
{
return (int)++aa;
}
A: 3
B: 0
C: Compile Error
D: 4
Right Answer : C
Que.16. Point out
the correct statement which correctly free the memory pointed to by 's' and 'p'
in the following program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
struct ex
{
int i;
float j;
char *s
};
struct ex *p;
p = (struct ex *)malloc(sizeof(struct ex));
p->s = (char*)malloc(20);
return 0;
}
A: free(p); , free(p->s);
B: free(p->s); , free(p);
C: free(p->s);
D: free(p);
Right Answer : B
Que.17. What will
be the output of the program?
#include<stdio.h>
int X=40;
int main()
{
int X=20;
printf("%d\n", X);
return 0;
}
A: 20
B: 40
C: Error
D: No Output
Right Answer : A
Que.18. What will
be the output of the program?
#include<stdio.h>
#define SQUARE(x)
x*x
int main()
{
float s=10, u=30, t=2, a;
a = 2*(s-u*t)/SQUARE(t);
printf("Result = %f", a);
return 0;
}
A: Result = -100.000000
B: Result = -25.000000
C: Result = 0.000000
D: Result = 100.000000
Right Answer : A
Que.19. What will
be the output of the program?
#include<stdio.h>
#define MAN(x, y)
((x)>(y)) ? (x):(y);
int main()
{
int i=10, j=5, k=0;
k = MAN(++i, j++);
printf("%d, %d, %d\n", i, j, k);
return 0;
}
A: 12, 6, 12
B: 11, 5, 11
C: 11, 5, Garbage
D: 12, 6, Garbage
Right Answer : A
Que.20. What is the
output of the program?
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
A: 20
B: 0
C: Garbage Value
D: Error
Right Answer : A
answer for que 3 is D not B
ReplyDelete