Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please need help in C programming CODE of the following: 1. Which of the following is a valid C statement? Explain what each valid statement

Please need help in C programming CODE of the following:

1. Which of the following is a valid C statement? Explain what each valid statement does. For invalid statements, explain the problem.

a. int items [ 5 ];

b. int items [ ];

c. int items = { 3, 7, 2 };

d. int items [ ] = { 3, 7, 2 };

e. int items [3] = { 3, 7, 2 };

2. Write a C statement that will create an integer array named nums, of length 3. Show two ways to initialize all the elements in the array to 10. One of the ways should use a for-loop.

3. Write C statements to create 3 separate arrays containing information for the elements below. Name the arrays symbols, numbers, and weights.

Name Symbol Number Weight

a. Oxygen O 8 15.999

b. Carbon C 6 12.011

c. Nitrogen N 7 14.007

d. Fluorine F 9 18.998

e. Boron B 5 10.81

4. Write the code to display all of the information saved in the arrays for just Oxygen.

5. Using a for-loop, write the code to display the symbols, numbers, and weights for all of the elements above, one element per line.

6. Write the code to locate and print the name and weight of the heaviest element.

7. Write the code to calculate and display the average weight of all the elements.

8. Define a 1-D array named matrixA of length 5. Use iteration to prompt the user to enter one single character at a time and save them in the array. Use iteration to display the characters stored, one per line.

9. Define a 2-D array named matrixB that contains the following values:

3 5 2

4 1 7

10. Use iteration to display all the values in the order shown.

11. Use iteration to prompt the user to enter a new value for each position. Read in each new value and assign it in the correct position.

12. Define an array called names that that contains the names of 3 of your friends.

13. Reassign the names in the array above to be appropriate nicknames for the friends.

Thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions