Answer to Question #259328 in C for Mr Z

Question #259328

2. Write a C program using an online C compiler (or Dev C++) that implements the following:-

• Declare a 10-element floating-point array; give the array a suitable name.

• Declare an integer variable (of type int); call it i

• Upon declaration, populate the array with 10 floating-point numbers of your choice.

• Prompt the user to enter a value between 0 and 9

• Read a number from the keyboard into i

• Display the ith element of the array


1
Expert's answer
2021-10-31T12:08:39-0400
#include<stdio.h>
int main(){
	float point[10];
	int i, k ;
	printf("Populating the array\n");
	for(k=0; k<10; k++){
		printf("Element %d: ",(k+1));
		scanf("%f", &point[k]);
	}
	
	printf("Enter a value between 0 and 9: ");
	scanf("%d", &i);
	printf("The ith element of the array is: %f", point[i]);
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS