C language

profilepakkaakhirla
CExam.docx

Question 1:

Write a program that calculates and prints the product of the even integers from 4 to 20.

Question 2:

Assume that integer array b[5] and integer pointer variable bPtr have been defined. Write a statement to set bPtr equal to the address of the first element in array b. Write a statement using pointer expression to reference the array element b[3].

Question 3:

Provide the definition for each of the following structures:

(a) Structure time containing integers hours, minutes and seconds.

(b) A structure called month that contains character arrays monthName[30], daysOfWeek[20], and an integer variable numberOfDays.

Question 4:

Assume that array int v[5]has been defined and its first element is at location 3000 in memory.

(a) How to initialise a pointer variable vPtr to point to v[0]?

(b) What is the memory address that the pointer vPtr points to after executing the following statement vPtr += 3;?Assume that an integer is stored in 4 bytes of memory.

Question 5:

Create a structure with members int a, int b and float c. Write a program that demonstrates how a structure variable value1 can be assigned to another structure variable value2. Print the value assigned to the structure variable value2.

Question 6:

Write a program to create a structure student, which contains name, roll and marks as its data member. Then, the program creates a structure variable s. Then, data name, roll and marks is taken from the user and stored in data members of structure variable s. Finally, the data entered by the user is displayed.

Question 7:

For each of the following, write a statement that performs the indicated task. Assume that integer variables a and b are defined and that a is initialized to 100.

(a) Define the variable ptr to be a pointer to an object of type int.

(b) Assign the address of variable a to pointer variable ptr.

(c) Assign the value of the object pointed to by ptr to variable b.

(d) Print the value of the object pointed to by ptr