CSE 240 FINAL EXAM COMPLETE
ANSWERS GRADED A+
◉ (C Programming)
What is printed by the following code?
#include <stdio.h>
int foo(int *n) {
*n = 30;
}
int main() {
int i=15;
foo(&i);
printf("i=%d\n",i);
i=10;
foo(&i);
printf("i=%d\n",i);
return 0;
}
Answer: i = 30
i = 30
◉ (C Programming)
,Given the following struct:
struct contact {
char name[32];
int phone;
char email[32];
};
Which code can be used to create a contact and store data?
Answer: struct contact x;
scanf("%s", x.name);
scanf("%d", &x.phone);
scanf("%s", x.email);
◉ (C Programming)
What is the output of the following program?
#include <stdio.h>
typedef enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun} WEEK;
int main() {
WEEK day;
day = Wed;
printf("%d",day);
, return 0;
}
Answer: 2
◉ (C Programming)
The following code is correct and print "Hello": (T/F)
if(2+2+2+2)
if(1)
printf("Hello");
Answer: True
◉ (C Programming)
What is the output of the below code?
#include <stdio.h>
int main() {
int a[5]={3,1,5,20,25};
int i,j,m;
i=*(a+1) - 1;
j=a[1] + 1;
m=a[j] + a[i];
printf("%d,%d,%d",i,j,m);
ANSWERS GRADED A+
◉ (C Programming)
What is printed by the following code?
#include <stdio.h>
int foo(int *n) {
*n = 30;
}
int main() {
int i=15;
foo(&i);
printf("i=%d\n",i);
i=10;
foo(&i);
printf("i=%d\n",i);
return 0;
}
Answer: i = 30
i = 30
◉ (C Programming)
,Given the following struct:
struct contact {
char name[32];
int phone;
char email[32];
};
Which code can be used to create a contact and store data?
Answer: struct contact x;
scanf("%s", x.name);
scanf("%d", &x.phone);
scanf("%s", x.email);
◉ (C Programming)
What is the output of the following program?
#include <stdio.h>
typedef enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun} WEEK;
int main() {
WEEK day;
day = Wed;
printf("%d",day);
, return 0;
}
Answer: 2
◉ (C Programming)
The following code is correct and print "Hello": (T/F)
if(2+2+2+2)
if(1)
printf("Hello");
Answer: True
◉ (C Programming)
What is the output of the below code?
#include <stdio.h>
int main() {
int a[5]={3,1,5,20,25};
int i,j,m;
i=*(a+1) - 1;
j=a[1] + 1;
m=a[j] + a[i];
printf("%d,%d,%d",i,j,m);