Escolar Documentos
Profissional Documentos
Cultura Documentos
2. int height=34;
void main()
{
int height=height;
cout << height;
}
A.
B.
C.
D.
3.
{
34
0
Undefined
Error
void main()
int a[3]={ 1,2,3 };
int i=1;
cout << a[i];
cout << i[a];
}
Is there a problem here? If not, what is the output?
4.
{
void main()
"Bunka"[2]='P';
}
Select the correct statement:
A. Error: lvalue required
B. Error: A string literal is a const char * and hence cannot be modified direct
ly.
C. A string literal has the data type char * and hence cannot be modified.
D. The code compiles but memory access error at run-time.
5.
{
static int i=5;
for(int j=i+3; i<j; i++)
printf("%3d",i);
printf("\n");
}
void main()
{
for(int i=0; i<3; i++)
foo();
}
6. # define MAX(a,b)a>b?a:b
void main()
{
int a=3,b=4;
printf("a=%d b=%d MAX=%d", a, b, MAX(a++,b++));
}
Select the correct output from the following:
A. a=4,b=5,MAX=5
B. a=4,b=5,MAX=6
C. a=5,b=6,MAX=5
D. a=4,b=6,MAX=5
void main()
union
{
int a;
struct
{
char b;
char c;
}ch;
}num;
num.a=300;
num.ch.c++;
printf("%d",num.a);
}
Select the correct output:
A. 456
B. 565
C. 556
D. 645
9. # include <conio.h>
# include <stdio.h>
void main()
{
static int a[]= { 0,1,2,3 };
static int *p[] = { a, a+1, a+2, a+3};
int **ptr=p;
*++*ptr;
printf("%d %d %d",ptr-p, *ptr-a, **ptr);
}
Select the corect output:
A. 110
B. 221
C. 011
D. 210
10. What is the output?
void main()
{
int n=4;
printf("%d %d %d", ++n, ++n, ++n);
}
A.
B.
C.
D.
567
765
444
555
printf("%d",func((x+3,y+=1),z--) );
}
Select the correct output from the above code
A. 6
B. 5
C. Compiler Error, Type mismatch
D. Compiles, but undefined behavior
12. What is the result of the following program?
void main()
{
char i;
for( i=0; i<200; i++)
{
}
printf("%d",i);
}
13. Write the output
void DoubleBoth(int i, int *j)
{
i*=2;
*j *=2;
}
void main()
{
int i=3,j=4;
DoubleBoth(i,&j);
printf("%d %d",i,j);
}
A.
B.
C.
D.
6
3
3
6
8
4
8
4
6
5
4
3
2
3
Undefined
Syntax error
{
saturday,
sunday
} today;
enum days yesterday;
int i=sunday;
yesterday=0;
printf("%d %d", i, yesterday);
}
Select the correct output
A. 1 0
B. 2 0
C. Compiler Error on Line 2
D. Compiler Error on Line 1
19. void main()
{
int n=0;
for(n=0;n<200;n++)
{
if (n>=101) continue;
printf("\n%d" ,n);
}
}
20. Variable declared within a bock of code are by default
A. Register
B. Extern
C. Static
D. Auto