Enter your search terms
Submit search form
Web
examineonline.googlepages.com
Online Exam
>>
Programming
>>
C/C++
>>
Test 4
Menu
Programming
COMPTIA
GMAT
English
IQ
DataBase
OS
MCSE
CISCO
Finance
Management
Health
Soft Skills
Web Building
Multimedia
Test 4
1 . main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; }
A.
Runtime error. Access violation
B.
Compile error. Illegal syntax
C.
None of the above
D.
Runtime error
2 . main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; }
A.
Gets into Infinite loop
B.
Compile error. Illegal syntax
C.
None of the above
D.
Runtime error.
3 . main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); }
A.
Some Integer not 100
B.
100
C.
Runtime error.
D.
None of the above
4 . main() { int i = 0xff ; printf("\n%d", i<<2); }
A.
1020
B.
512
C.
4
D.
1024
5 . #define SQR(x) x * x main() { printf("%d", 225/SQR(15)); }
A.
15
B.
225
C.
1
D.
none of the above
6 . union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); }
A.
40, 4, 0
B.
100, 4, 0
C.
0, 0, 0
D.
4, 4, 0
7 . union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); }
A.
1, 100, 1
B.
40, 4, 4
C.
4, 4, 4
D.
None of the Above
8 . main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p }
A.
Compile error
B.
1.00000
C.
Runtime error.
D.
Runtime error.
9 . main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); }
A.
Compile error
B.
0, 0
C.
Runtime error.
D.
the first two values entered by the user
10 . main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); }
A.
Compile error
B.
"Hello world"
C.
Runtime error.
D.
"hello world"
11 . main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); }
A.
Compile error
B.
I am OK
C.
Runtime error.
D.
I am O
12 . How will you print % character?
A.
printf("%%")
B.
printf("\\%")
C.
printf("\%")
D.
printf("\%%")
13 . const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); }
A.
none of the above
B.
4
C.
2
D.
0
14 . struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); }
A.
Name
B.
compile error
C.
Your Name
D.
Runtime error
15 . struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); }
A.
Your Name Your Name
B.
Your Address, Your Address
C.
Your Name, Your Address
D.
None of the above
16 . main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); }
A.
HelloWorld
B.
Hello World
C.
Hello
D.
None of the above
17 . main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); }
A.
None of the above
B.
"HelloWorld"
C.
"Hello World"
D.
"Hello"
18 . void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); }
A.
Ok it worksWill this work?
B.
Will this work?
C.
Ok it works
D.
None of the above
19 . main() { printf("%d, %d", sizeof('c'), sizeof(100)); }
A.
4, 100
B.
2, 100
C.
2, 2
D.
4, 4
20 . main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); }
A.
none of the above
B.
4
C.
100
D.
2
21 . main() { int c = 5; printf("%d", main||c); }
A.
none of the above
B.
0
C.
5
D.
1
22 . main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); }
A.
none of the above
B.
random number
C.
-456
D.
456
23 . void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); }
A.
10, 11
B.
10, 9
C.
10, 10
D.
none of the above
24 . main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); }
A.
20, 9, 19, 10
B.
20, 9, 20, 10
C.
20, 10, 20, 10
D.
19, 9, 20, 10
25 . main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n"", x--); } }
A.
0, 1, 2, 3, 4
B.
1, 2, 3, 4, 5
C.
4, 3, 2, 1, 0
D.
none of the above
Test Name :
Test 4
Category :
C/C++
Number of Question :
25
Pass Score :
80
Test Result
Your Score :
Passing Score :
80
Result :
Copyright by
VanTuMinh
© 2007