Exam: “Programming 1” , course 1, ACS,year 2023-2024
Part I , v2
Surround the true answer of the following questions:
1. What is the equivalent to the expression: d= –c + b++;
A. c=c-1; b=b+1; d=c+b;
B. c=c-1; d=c+b; b=b+1;
C. c=c+1; d=c+b; b=b+1;
D. c=c-1; b=b-1; d=c+b;
2. Every console C program has to contain function
A. system
B. start
C. main
D. standard
3. Which of the following is a properly defined struct?
A. struct {int a;}
B. struct a_struct {int a;}
C. struct a_struct int a;
D. struct a_struct {int a;};
4. Which properly declares a variable of struct ab?
A. struct ab;
B. ab var;
C. ab;
D. int ab;
5. What is the return type of the function with prototype: “int func(char x, float v,
double t);”
A. char
B. int
C. float
D. double
6. Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double
7. Which of the following gives the memory address of integer variable a?
A. *a;
B. a;
C. &a;
D. address(a);
8.What does the term “bit” mean?
A. a decimal digit, which can accept values from 0 to 10.
B. a binary digit, which can accept values from 0 to 1.
C. an octal digit, which can accept values from 0 to 8.
D. none of the above
9. How many bits are there in one byte?
A. 10
B. 2
C. 8
D. 12
10. Which of the following gives the value stored at the address pointed to by the pointer a?
A. a;
B. val(a);
C. *a;
D. &a;
Exam: “Programming 1” , course 1,
ACS,
year 2023-2024
Part II , v2
Write what will be displayed on the screen after execution of the following 3 test programs:
//Test2-1
#include
#include
int main( void)
{ int a=3, b=2, c=4;
printf(“\n After init: a=%d, b=%d, c=%d”, a,b,c);
a += b– + ++c ;
printf(“\n Res: a=%d, b=%d, c=%d”, a,b,c);
printf(“\n Press any key to end…”); getch();
}
//Test2-2
#include
#include
float func1(float *ar, int N);
int main(void)
{ float ar[]={2.0,5.0,3.0,2.0};
int N;
float res;
N=sizeof(ar)/sizeof(float);
res=func1(ar,N);
printf(“\nTest2: B E G I N”);
printf(“\n N=%d, res= %7.2f\n”, N, res);
system(“pause”); return 0;
}
float func1(float * ar, int N)
{ int i;
float f=0;
for (i=0; i