148k views
4 votes
Please answers the following two questions using Language C.

1) Given that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the year in order (i.e., January, February, etc.), write a statement that writes to standard output the element corresponding to October.Do not write anything else out to standard output .
2) Given an int variable count that has already been declared , write a for loop that prints the integers 50 through 1, separated by spaces. Use no variables other than count.

User Eadaoin
by
5.1k points

1 Answer

4 votes

Answer:

The code to this question can be given as:

Code 1:

printf("%d\\",monthSales[9]); //prints value.

Code 2:

for (int count=50; count>0; count--) //for loop

{

printf("%d ",count); //print number that is separated by spaces.

}

Explanation:

The explanation of the above code as follows:

  • In code 1, It is given that an integer array is defined that is "monthSales" which contains the sales data. We know that array indexing always starts with 0. So, in October month will contain index value 9.
  • In code 2, We use the for loop in the loop we an integer variable that is count. Which prints number 50 to 1 in reverse order and all numbers separated by space.
User Brian Berns
by
5.7k points