C Programming Exam Questions and Answers
C Programming Exam Questions and Answers
ISMIN 1A
Programming 1
C programming exam
Philippe LALEVÉE
January 7, 2010
Notes.
Please indicate your first name and last name at the top of this page.
You have one hour to answer the questions.
Documents are not allowed.
At the end of the exam, you will submit this paper, containing your answers.
This exam consists of 30 open-ended questions (short answers)
Annotated questions(*2) are worth double the points of non-annotated questions.
Those marked (*3) are worth triple points.
There is no downside.
1
Part 1. Open Questions
2.(*2) Give the declaration of an array where each of its 20 elements is a structure to
three fields: an integer number, an integer pointer, and an array of 15 characters.
Assuming this initialized table, give the expression to place in the field
Print the 4th element of the array, the address of the field number of the 11th element.
2
Propose a version without using the array access operator ([]).
void f(int i) {
int* j;
*j = i;
}
6. (*2) Why must we place an '&' in front of the variable 'ime' in the following code:
int ime;
scanf("%d", &ime);
3
float ill;
ille = 2/3 100.0
* ;
Why?
11. Let ge, an array of 10 characters. Provide the instruction to input from the keyboard a
string, without using the character '&'.
4
Give the values of the variables after the execution of this program.
The strcpy function allows you to copy a string of characters into another existing one.
Here is its prototype:
char strcpy
* ( char destination,
* char source) *;
Write this function without using arrays or the [] operator (only pointers)
and pointer accesses).
16. Let the following declaration be: char mant[] = { 'a', 'b' }.
What is worth it?
5
18. Give the declaration of a function without parameters that returns the address of an integer.
20. Let erne be an array of 10 integers. Provide the instruction to input the 3rd one from the keyboard.
whole
23.(*2) What is the value of the variable flower in the following code:
Why?
24. Let the following declaration be, char tab[] = "". What does the array tab contain?
6
25. Give the declaration of a function without parameters that does not return any value.
27. What is the value of the variable 'ernet' at the end of the following code?
int main() {
int tab[MAX];
tab[2] = 2 ;
printf("%d", tab[MAX-8]);
}
Does this program compile? If so, what does it display?
7
default: printf("NEGATIVE OR NOT A NUMBER"); break;
}
Rewrite the switch instructions using only if statements.
int main() {
int p* ;
g(p) ;
printf("%d\n", p); *
}
What is displayed?