In: Computer Science
1) Using either emacs or vi write a C program that reads 100
integers from stdin into a 2-dimensional 10x10 array. The program
will read one additional integer which is
used to multiply each element of the array. The final array should
be printed to stdout as follows:
Run 1:
Enter 100 integers: 1 2 3 4 5 6 7 8 9 10 11 …. 100
Enter factor: 3
Result:
3 6 9 12 … 30
33 36 39 42 … 60
. … 90
.
.
273 276 279 282 … 300
SOURCE CODE
#include<stdio.h>
int main(){
/* 2D array declaration*/
int disp[10][10];
/*Counter variables for the loop*/
int i, j, fact;
printf("Enter 100 integers:");
for(i=0; i<10; i++) {
for(j=0;j<10;j++) {
scanf("%d", &disp[i][j]);
}
}
printf("Enter Factor:");
scanf("%d", &fact);
printf("Two Dimensional array elements:\n");
for(i=0; i<10; i++) {
for(j=0;j<10;j++) {
printf("%d ", disp[i][j]*fact);
if(j==9){
printf("\n");
}
}
}
return 0;
}
SCREENSHOT
please give a upvote if u feel helpful.