An Array in a C program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

An Array in a C program

write a c program that inserts a 6 floating numbers in an array and an integer in a variable, then the program multiply each cell of the array by the integer then store the result in the corresponding cell..

29th Apr 2017, 9:27 PM
Joe Rostom
Joe Rostom - avatar
1 Answer
+ 9
int main(){ int a, i; float arr[6]; printf("insert an integer: "); scanf("%d", &a); // insert the elements of the array for(i=0; i<6; i++){ printf("insert value of arr[%d] = ", i); scanf("%f", arr[i]); } // multiply each cell of the array by a for(i=0; i<6; i++){ arr[i] *= a; } }
29th Apr 2017, 11:52 PM
Mohammad Dakdouk
Mohammad Dakdouk - avatar