Enter your search terms
Submit search form
Web
examineonline.googlepages.com
Online Exam
>>
Programming
>>
C/C++
>>
Test 3
Menu
Programming
COMPTIA
GMAT
English
IQ
DataBase
OS
MCSE
CISCO
Finance
Management
Health
Soft Skills
Web Building
Multimedia
Test 3
1 . main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } }
A.
5, 3, 1
B.
4, 3, 2, 1, 0
C.
5, 4, 3, 2,1
D.
none of the above
2 . main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } }
A.
5, 3, 1, -1, 3
B.
5, 2, 1
C.
5, 3, 1
D.
None of the above
3 . main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } }
A.
256, 512
B.
512, 512
C.
256, 256
D.
Compile error
4 . main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } }
A.
1, 2, 4, 8, 16
B.
0, 1, 2, 4, 8
C.
0, 1, 2, 3, 4
D.
5, 4, 3, 2, 1
5 . main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } }
A.
128, 64, 32, 16, 8
B.
256, 128, 64, 32, 16
C.
512, 256, 128, 64, 32
D.
64, 32, 16, 8, 4
6 . main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } }
A.
512, 512, 512, 512, 512
B.
256, 256, 0, 0, 0
C.
512, 256, 0, 0, 0
D.
256, 256, 256, 256, 256
7 . main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } }
A.
none of the above
B.
compile error
C.
OK I am gone
D.
OK I am done
8 . main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } }
A.
none of the above
B.
compile error
C.
OK I am gone
D.
OK I am done
9 . main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } }
A.
0, -513
B.
512, 0
C.
0, 513
D.
0, 0
10 . What would be the output of the following program? main() { int i=4; switch(i) { default: printf("\n A mouse is an elephant built by the Japanese"); case 1: printf(" Breeding rabbits is a hair raising experience"); break; case 2: printf("\n Friction is a drag"); break; case 3: printf("\n If practice make perfect, then nobody's perfect"); } }
A.
A mouse is an elephant built by the Japanese
B.
Breeding rabbits is a hare raising experience
C.
A mouse is an elephant built by the Japanese Breeding rabbits is a hare raising experience
D.
None of the above
11 . What is the output of the following program? #define SQR(x) (x*x) main() { int a,b=3; a= SQR(b+2); printf("%d",a); }
A.
25
B.
11
C.
Error
D.
Garbage Value
12 . In which line of the following, an error would be reported? 1. #define CIRCUM(R) (3.14*R*R); 2. main() 3. { 4. float r=1.0,c; 5. c= CIRCUM(r); 6. printf("\n%f",c); 7. if(CIRCUM(r))==6.28) 8. printf("\nGobbledygook"); 9. }
A.
Line 1
B.
Line 5
C.
Line 6
D.
Line 7
13 . We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()
A.
True
B.
False
14 . If the program (myprog) is run from the command line as myprog 1 2 3 , What would be the output? main(int argc, char *argv[]) { int i; for(i=0;i<argc;i++) printf("%s",argv[i]); }
A.
1 2 3
B.
C:\MYPROG.EXE123
C.
MYP
D.
None of the above
15 . If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output? main(int argc, char *argv[]) { int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]); printf("%d",j); }
A.
1 2 3
B.
6
C.
error
D.
"123"
16 . If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday What would be the output? main(int argc, char *argv[]) { while(--argc >0) printf("%s",*++argv); }
A.
myprog monday tuesday wednesday thursday
B.
monday tuesday wednesday thursday
C.
mondaytuesdaywednesdaythursday
D.
myprog tuesday thursday
17 . What would be the output of the following program? main() { int y=128; const int x=y; printf("%d",x); }
A.
128
B.
Garbage value
C.
Error
D.
0
18 . Following declarations are same const char *s; char const *s;
A.
True
B.
False
19 . What would be the output of the following program? main() { char near * near *ptr1; char near * far *ptr2; char near * huge *ptr3; printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3)); }
A.
1 1 1
B.
1 2 4
C.
2 4 4
D.
4 4 4
20 . Following declarations are different from one another const char *const s; char const *const s;
A.
True
B.
False
21 . If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output? main(int argc, char*argv[]) { printf("%c",**++argv); }
A.
m
B.
f
C.
myprog
D.
friday
22 . If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output? main(int argc, char *argv[]) { printf("%c",*++argv[1]); }
A.
r
B.
f
C.
m
D.
y
23 . Would the following program compile? main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n%u%u",j,k); }
A.
True
B.
False
24 . According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
A.
main(int argc, char *argv[])
B.
main(argc,argv) int argc; char *argv[];
C.
main() {int argc; char *argv[]; }
D.
None of the above
25 . What would be the output of the following program? main() { const int x=5; int *ptrx; ptrx=&x; *ptrx=10; printf("%d",x); }
A.
5
B.
10
C.
Error
D.
Garbage Value
Test Name :
Test 3
Category :
C/C++
Number of Question :
25
Pass Score :
80
Test Result
Your Score :
Passing Score :
80
Result :
Copyright by
VanTuMinh
© 2007