+ All Categories
Home > Documents > EXAM 1 REVIEW!

EXAM 1 REVIEW!

Date post: 17-Jan-2016
Category:
Upload: nicki
View: 26 times
Download: 0 times
Share this document with a friend
Description:
EXAM 1 REVIEW!. The Gauntlet!!!!. Question 1: The following is a preprocessor directive:. int main (void) double fct1 (double a, double b); #define N 100 int numbers=100;. Question 2: The following demos FILE input. fscanf(stdin, “%d”, &data); fscanf(“%d”, &data); - PowerPoint PPT Presentation
33
EXAM 1 REVIEW! The Gauntlet!!!!
Transcript
Page 1: EXAM 1 REVIEW!

EXAM 1 REVIEW!The Gauntlet!!!!

Page 2: EXAM 1 REVIEW!

Question 1: The following is a preprocessor directive:

a) int main (void)

b) double fct1 (double a, double b);

c) #define N 100

d) int numbers=100;

Page 3: EXAM 1 REVIEW!

Question 2: The following demos FILE input

a) fscanf(stdin, “%d”, &data);

b) fscanf(“%d”, &data);

c) fprintf(fpout, “%d”, data);

d) fscanf(fpin, “%d”, &data);

Page 4: EXAM 1 REVIEW!

Question 3: int a; a=31%11%3;

a) a = 0

b) a = 1.9375

c) a = Divide by zero so NaN

d) a = 1

Page 5: EXAM 1 REVIEW!

Question 4: int b; b=14/3*3;

a) b = 14

b) b = 12

c) b = 6

d) b = 1

Page 6: EXAM 1 REVIEW!

Question 5: How many errors can you spot?

int x,y; double sum;

scanf(“%d %d”,x,y);

x+y = sum;

printf(“Sum=%d\n”, sum);

a) None

b) 5

c) 2

d) 4

Page 7: EXAM 1 REVIEW!

Question 6: Which is illegal?

a) int Double;

b) double return;

c) unsigned short static int x = -1;

d) char pause = 5;

Page 8: EXAM 1 REVIEW!

Question 7: Given: double x=3.0, y= 4.0, z=2.0; Which is FALSE?

a) x = 1.0 && x == 2.0

b) x > z && y > z

c) x = 2.0 || y != 4.0

d) z < = x && x <= y

Page 9: EXAM 1 REVIEW!

Question 8: Which function call is valid double fct(int p, double q); //function prototype

int x,y,z; double a,b,c; //declarations in main()

a) x = fct(x,y)

b) x = fct(y,a)

c) a = fct(b,c)

d) a = fct(x,a);

Page 10: EXAM 1 REVIEW!

Question 9: printf(“$$%c\t%%\t%c”,’1’,’!’); What prints?

a) $1%!

b) $1 % !

c) $’1’%% !

d) $$1 % !

Page 11: EXAM 1 REVIEW!

Question 10: printf(“Sum = %8.3lf”,7.8); What prints?

a) Sum = ▒ ▒ ▒ ▒ ▒ ▒ ▒ 7.800

b) Sum = ▒ ▒ ▒ ▒ ▒ 7.800

c) Sum = ▒ ▒ ▒ 7.800

d) Sum = 7.800

Page 12: EXAM 1 REVIEW!

Question 11: What prints?

/*Section of code in main() */int n=5, m=3;

n = fct(m);printf(“n = %d m = %d\n”,n,m);

/*function*/int fct(int n){

int m = 4;return (n + m);

}

Page 13: EXAM 1 REVIEW!

Question 12: What prints?

int n=5, m;

for(m=0; m<n; m++)if(m=n)

printf(“m=%d”,m);

Page 14: EXAM 1 REVIEW!

Question 13: What prints?

int n=5, m=0;

while(--n)printf(“%d\t”,n);

Page 15: EXAM 1 REVIEW!

Question 14: What prints?

//Section in main()int n[]={5,4,3}, m[]={1, 2, 3};fct1(3,n,m);printf(“%d %d”,m[2],n[0]);

void fct1(int n, int a[], int b[]){int j;for(j=0; j<(n-1); j++){

b[j] = b[j] - b[j+1];a[j] = a[j] - 2*b[j];

}}

Page 16: EXAM 1 REVIEW!

Question 15: What prints?

//Section in main()int n[]={5,4,3}, m[]={1, 2, 3};m[2] = fct1(3,n,m);printf(“%d %d”,m[2],n[0]);

int fct1(int n, int a[], int b[]){int j;for(j=0; j<(n-1); j++){

b[j] = b[j] - b[j+1];a[j] = a[j] - 2*b[j];

}return (b[j]-1);}

Page 17: EXAM 1 REVIEW!

EXAM 1 REVIEW!Last person standing wins!!!

Page 18: EXAM 1 REVIEW!

Question 1: The following is a preprocessor directive:

a) int main (void)

b) double fct1 (double a, double b);

c) #define N 100

d) int numbers=100;

Page 19: EXAM 1 REVIEW!

Question 2: The following is an example of FILE input

a) fscanf(stdin, “%d”, &data);

b) fscanf(“%d”, &data);

c) fprintf(fpout, “%d”, data);

d) fscanf(fpin, “%d”, &data);

Page 20: EXAM 1 REVIEW!

Question 3: int a; a=31%11%3;

a) a = 0

b) a = 1.9375

c) a = Divide by zero so NaN

d) a = 1

Page 21: EXAM 1 REVIEW!

Question 4: int b; b=14/3*3

a) b = 14

b) b = 12

c) b = 6

d) b = 1

Page 22: EXAM 1 REVIEW!

Question 5: How many errors can you spot?

int x,y; double sum;

scanf(“%d %d”,x,y);

x+y = sum;

printf(“Sum=%d\n”, sum);

a) None

b) 5

c) 2

d) 4

int x,y; double sum;

scanf(“%d %d”,&x,&y);

sum = x+y;

printf(“Sum = %lf\n”, sum);

Page 23: EXAM 1 REVIEW!

Question 6: Which is illegal?

a) int Double;

b) double return;

c) unsigned short static int x = -1;

d) char pause = 5;

Page 24: EXAM 1 REVIEW!

Question 7: Given: double x=3.0, y= 4.0, z=2.0; Which is FALSE?

a) x = 1.0 && x == 2.0

b) x > z && y > z

c) x = 2.0 || y != 4.0

d) z < = x && x <= y

Page 25: EXAM 1 REVIEW!

Question 8: Which function call is valid double fct(int p, double q); //function prototype

int x,y,z; double a,b,c; //declarations in main()

a) x = fct(x,y)

b) x = fct(y,a)

c) a = fct(b,c)

d) a = fct(x,a);

Page 26: EXAM 1 REVIEW!

Question 9: printf(“$$%c\t%%\t%c”,’1’,’!’); What prints?

a) $1%!

b) $1 % !

c) $’1’%% !

d) $$1 % !

Page 27: EXAM 1 REVIEW!

Question 10: printf(“Sum = %8.3lf”,7.8); What prints?

a) Sum = ▒ ▒ ▒ ▒ ▒ ▒ ▒ 7.800

b) Sum = ▒ ▒ ▒ ▒ ▒ 7.800

c) Sum = ▒ ▒ ▒ 7.800

d) Sum = 7.800

Page 28: EXAM 1 REVIEW!

/*Section of code in main() */int n=5, m=3;

n = fct(m);printf(“n = %d m = %d\n”,n,m);

/*function*/int fct(int n){

int m = 4;return (n + m);

}

Question 11: What prints?

n = 7 m = 3

Page 29: EXAM 1 REVIEW!

Question 12: What prints?

int n=5, m;

for(m=0; m<n; m++)if(m=n)

printf(“m=%d”,m);

m=5

Page 30: EXAM 1 REVIEW!

Question 13: What prints?

int n=5, m=0;

while(--n)printf(“%d\t”,n);

4 3 2 1

Page 31: EXAM 1 REVIEW!

Question 14: What prints?

//Section in main()int n[]={5,4,3}, m[]={1, 2, 3};fct1(3,n,m);printf(“%d %d”,m[2],n[0]);

void fct1(int n, int a[], int b[]){int j;for(j=0; j<(n-1); j++){

b[j] = b[j] - b[j+1];a[j] = a[j] - 2*b[j];

}}

3 7

Page 32: EXAM 1 REVIEW!

Question 15: What prints?

//Section in main()int n[]={5,4,3}, m[]={1, 2, 3};m[2] = fct1(3,n,m);printf(“%d %d”,m[2],m[0]);

int fct1(int n, int a[], int b[]){int j;for(j=0; j<(n-1); j++){

b[j] = b[j] - b[j+1];a[j] = a[j] - 2*b[j];

}return (b[j]-1);}

2 -1

Page 33: EXAM 1 REVIEW!

GOOD LUCK!!!


Recommended