In: Computer Science
11.2 Exercise 2:
You are required to write a program that creates a float array of size 90. Using a for loop, populate the array element whose index is the value of the loop variable with the value of the loop variable (e.g. array[0] = 0, array[1] = 1 etc.) Using a second loop display the loop index and the value in the array - each pair of numbers is to be displayed on a new line.
Hi, could you please hlp me with this simple c programming problem? I'm not sure what the part in bold is asking. Below is my code for the problem so far.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// Declare variables
int Array[90];
int i;
// Loop from 0 to 90 inclusive
for ( i = 0 ; i < 91 ; i++ )
{
Array[i] = i;
printf ("Array number %d contains value %d\n", i, Array[i]);
}
// Exit the application
return 0;
}
Answer for the above the question:
I understood the question .
1.As per the problem statement he want you to create a float Array[90] but you create int Array .
2.And He want two for loops in the problem one for assigning the values another one for displaying the values .
3.In printf() statement you need to white space charater "%f" display float array .
PS: If you have any doubt mention in the comment section . I will try to solve it as soon as possible.