1 / 34

FINAL EXAM REVIEW!!

FINAL EXAM REVIEW!!. Lets play C-eopardy!!! (Answer in the form of answers!!) Feel free to hum along!. Arrays. Functions & Macros. Strings. Pointers. Loops. 100. 100. 100. 100. 100. 200. 200. 200. 200. 200. 300. 300. 300. 300. 300. Question:. Given the following:

oded
Télécharger la présentation

FINAL EXAM REVIEW!!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FINAL EXAM REVIEW!! Lets play C-eopardy!!! (Answer in the form of answers!!) Feel free to hum along!

  2. Arrays Functions & Macros Strings Pointers Loops 100 100 100 100 100 200 200 200 200 200 300 300 300 300 300

  3. Question: Given the following: function prototype: void my_func(int array[][3]); variable declaration: int X[2][3]; Which function call can you use to pass a 2-dimensional array to a function? my_func(X); my_func(&X[0][0]); my_func(X[0]);

  4. Answer All of them

  5. Question What is printed: int a[3][3]={0}, i,j; for(i=0;i<3;i++) for(j=i;j<3;j++) a[i][j]=i*j; for(i=0;i<3;i++) printf(“%d\t”,a[i][1]);

  6. Answer 0 1 0

  7. Question What is printed: int a[10]={0}, n=27212, abc; while(n>0) { abc=n%10; if(a[abc]) { printf(“%d\t”,abc); break; } a[abc]=1; n/=10; }

  8. Answer 2

  9. Question Given the following: #define DOUBLE(x) (2*x) What is the output for printf(“%d”,DOUBLE(1+2));

  10. Answer 4

  11. Question Write the following equation as a C statement using functions from the math.h library. y=(en ln(b))2

  12. Answer y=pow(exp(n*log(b)),2);

  13. Question Given the following program: main() { int n = 10; printf(“%d”,funct1(n)); } int funct1(int n) { if(n>0) return(n + funct1(n-1)); } What is the o/p ?

  14. Answer 55

  15. Question Given the following program: #include <stdio.h> #define ROWS 3 #define COLUMNS 4 int z[ROWS][COLUMNS] = {1,2,3,4,5,6,7,8,9,10,11,12}; int main() { int a, b, c; for(a=0;a<ROWS,++a) { c = 999; for(b=0;b<COLUMNS;++b) if(z[a][b] < c) c = z[a][b]; printf(“%d ”,c); } What is the o/p?

  16. Answer 1 5 9 (smallest value within each row)

  17. Question What is the output of the following code fragment: inti; char x[80] = “gorilla”; char y[80] = “giraffe”; char z[3][80]; strcpy(z[0],y); strcpy(z[1],strcat(x,y)); strcpy(z[2],x); for(i=0;i<3;i++) printf(“%s\n”,z[i]);

  18. Answer giraffe gorillagiraffe gorillagiraffe

  19. Question What is the final value of string s1? strcpy(s1,"computer"); strcpy(s2,"science"); if(strcmp(s1,s2) < 0) strcat(s1,s2); else strcat(s2,s1); s1[strlen(s1)-6] = '\0';

  20. Answer computers

  21. Question If ‘i’ is a variable and ‘p’ points to ‘i’, which of the following expression are aliases for ‘i’ ? *p e) *i &p f) &i *&p g) *&i &*p h) &*i

  22. Answer a) g)

  23. Question Consider following declaration: float table[2][3] = { {1.1, 1.2, 1.3}, {2.1, 2.2, 2.3} }; What is the value of ? *(*(table+1));

  24. Answer 2.1

  25. Question Given: int x[]={-1,-2,-3,-4}, *px, **ppx; px=x; ppx=&px; Which command will display -3. A: printf(“%d”,**ppx+2); B: printf(“%d”,*(*ppx+2)); C: printf(“%d”,*ppx+2); D: printf(“%d”,*(ppx+2));

  26. Answer B

  27. Question Given the following: int i=0,n=465; do { n/=10; i++; } while(n>0); printf(“i=%d\n”,i); What is printed?

  28. Answer 3

  29. Question What is printed: int i=10; while(i-- +2); printf(“%d”,i);

  30. Answer -3

  31. Question What is displayed by the following code: #include <stdio.h> main() { int i,j,x=0; for (i=0; i<5; ++i) { for(j=0;j<i;++j) x += (i+j-1); printf(“%d”, x); break; } printf(“\nx = %d”,x); }

  32. Answer 0 x = 0

  33. Arrays Functions & Macros Strings Pointers Loops 100 100 100 100 100 200 200 200 200 200 300 300 300 300 300

More Related