My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
C Debugging-1
Posted Date: 16 May 2008 Resource Type: Articles/Knowledge Sharing Category: Placement Papers
|
Posted By: Shanthi M Member Level: Diamond Rating: Points: 1
|
|
|
|
Debugging –C
1. What is the output? void main () { char far *farther,*farthest; printf ("%d %d", sizeof (farther), sizeof (farthest)); } a) 2 2 b) 2 4 c) 4 2 d) 4 4
2. What is the output? void main () { int i=400, j=300; printf ("%d %d"); } a) Prints Nothing b) 400 300 c) 300 400 d) 400 400
3. What is the output?
void main () { int i; printf ("%d", scanf ("%d",&i)); // value 10 is given as input } a) 10 b) 100 c) 1 d) 0
4. What is the output? void main( ) { int i=0; for (i=0;i<20;i++) { switch (i){ case 0: i+=5; case 1: i+=2; case 5: i+=5; default: i+=4; break; } printf ("%d", i); } } a) 0,5,9,13,17 b) 5,9,13,17 c) 12,17,22 d) 16,21 5. What is the output? void main () { int i=7; printf ("%d",i++*i++); } a) 49 b) 64 c) 56 d) Error 6. What is the output? void main() { int count=10,*temp,sum=0; temp=&count; *temp=20; temp=∑ *temp=count; printf("%d %d %d ",count,*temp,sum); } a) 10 10 10 b) 10 20 20 c) 10 10 20 d) 20 20 20 7. What is the output? void main () { int a[10]; printf(“%d”,*a+1-*a+3); } a) 4 b) 5 c) 6 d) Garbage Value 8. If you run the code below, what gets printed out?
String s=new String ("Bicycle"); int iBegin=0; int iEnd=4; System.out.println (s.substring (iBegin, iEnd));
a) Bicy b)Bicyc c)Bic d) ic 9. What is the output? enum colors{BLACK,BLUE,GREEN} void main( ) { printf(“%d %d %d”,BLACK,BLUE,GREEN); } a) BLACK BLUE GREEN b) 0 1 2 c) 1 2 3 d) GREEN BLUE BLACK 10. What is the output? void main( ) { char *str1=”abcd”; char str2[]=”abcd”; printf(“%d %d”,sizeof (str1),sizeof(str2)); } a) 4 4 b) 5 5 c) 2 5 d) 2 4 11. What is the output? #include aaa( ){ printf(“Hi”); } bbb( ){ printf(“Hello”); } ccc( ) { printf(“Bye”); } void main( ) { int (*ptr[3])( ); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2]( ); } a) Hi b) Hello c) Bye d) Prints Nothing 12. What is the output? #include void main( ) { int a=0; int b=20; char x=1; char y=10; if(a,b,x,y) printf(“Hello”); else printf(“Bye”); } a) Hello b) Bye c) Prints Nothing d) Error in the program 13. What is the output?
#include void main( ) { int i=10,j=20; j=i,j ? (i,j)?i:j:j; printf(“%d %d”,i,j); }
a) 20 20 b) 20 10 c) 10 20 d) 10 10
14. What is the output? #include void main( ) { int i=5; printf(“%d”,i= + +i= =6); }
a) 0 b) 1 c) 5 d) 6
15. What is the output? #include #include void main( ) { int arr2D [3][3]; printf(“%d\n”, ((arr2D= =*arr2D)&&(*arr2D= =arr2D [0]))); } a) 1 b) 0 c) Garbage value d) Error in compilation
16. What is the output? #include #include void main( ) { char str[5]=”Hello”; static char *ptr; ptr=str; printf(“%s”,ptr); }
a) Illegal declaration b) Illegal Inititalization c) Hello d) Address of str
17. What is the output? #include #include void main( ) { FILE *fp; char str[80]; /* try.txt contains only one line.its the computer science world!*/ fp=fopen(“try.txt”,”r”); while(fgets(str,80,fp)!=EOF) puts(str); }
a) Its the Computer Science World b) File does not open correctly c) Error in reading the contents from file d) Prints “Its the computer Science World” Infinite times
18. What is the output? #include #include #define inc(x) x++ void main( ) { int num=4; printf(“%d”, inc(num)++); } a) 6 b) 5 c) Error in macro defined d) Error in compilation
19. What is the output? #include void main( ) { int num; num=func(20); printf(“%d”,num); } int func(int num) { num >20 ? return(100) : return(200); } a) 100 b) 200 c) 20 d) Error
20. What is the output? #include #include #define printf scanf #define scanf printf void main( ) { scanf(“Hi”); printf(“Hello”); }
a) Hi b) Hello c) Waits for Input and displays Hello d) Displays Hi and Waits for Input
ANSWERS
1. C 2. B 3. C 4. D 5. C 6. D 7. A 8. A 9. B 10. C 11. C 12. A 13. D 14. B 15. A 16. B 17. D 18. D 19. D 20. C
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
Watch TV Channels
Watch Asianet TV onlineKairali TV in InternetSurya TV onlineAmritha TV Channel
|