0% found this document useful (0 votes)
2 views1 page

C Array Exercises and Solutions

The document presents an exercise involving an array of integers in C. It asks for specific values from the array, C statements for assigning and printing values, and calculating the sum of elements. The exercise covers array indexing, variable assignment, and output to the console.

Uploaded by

wakadalamark
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

C Array Exercises and Solutions

The document presents an exercise involving an array of integers in C. It asks for specific values from the array, C statements for assigning and printing values, and calculating the sum of elements. The exercise covers array indexing, variable assignment, and output to the console.

Uploaded by

wakadalamark
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arrays Exercise:

a) Given the array below:


int nums[5] = {10, 20, 30, 40, 50};
i) What is the value of nums[1]?
ii) What is the value of nums[3]?
iii) Write a C statement that assigns the value 100 to the first element of the array.
iv) Write a C statement that prints the value of the fourth element of the array to
the console.
v) Calculate the sum of the first two elements of the array and write a C statement
to print the sum to the console.
vi) Write a C statement that creates a new variable named result and assigns it the
value of the last element of the array. Then, write another C statement to print
the value of result to the console.

You might also like