Question

In: Computer Science

1) Using either emacs or vi write a C program that reads 100 integers from stdin...

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

Solutions

Expert Solution

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.


Related Solutions

Code is in C Write a program that reads integers from stdin. Once it reaches the...
Code is in C Write a program that reads integers from stdin. Once it reaches the * end of the input, it prints the smallest absolute value among those * of the numbers it read. * * For example, if * 4, 6 -3, 3, -2, 13, -4 * are read from stdin, the program should print 2. * * If the end of file is reached before any integer is seen, the * number printed should be INT_MAX (defined...
write these programs in c++ using getch() function Write a program that reads 20 integers from...
write these programs in c++ using getch() function Write a program that reads 20 integers from a user using a while loop and determines and prints whether each of those integers is an even number. Write a program that uses a while statement to read integers from a user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters -1.
(C++) Write a program that reads a list of integers from the keyboard and print out...
(C++) Write a program that reads a list of integers from the keyboard and print out the smallest number entered. For example, if user enters 0 3 -2 5 8 1, it should print out -2. The reading stops when 999 is entered.
JAVA Write a program that reads the integers between -100 and 100 and counts the occurrences...
JAVA Write a program that reads the integers between -100 and 100 and counts the occurrences of each with ascending order. input: line1:number of figures line2:number Sample Input 5 -3 100 -1 -2 -1 Sample Output -3 1 -2 1 -1 2 100 1
Please write code in C, thank you. Write a program that reads a list of integers,...
Please write code in C, thank you. Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 2 4 6 8 10 the output is: all even Ex: If the input is: 5 1 3 5 7 9...
1. Write a C++ program, for.cpp, that reads three integers. The first two specify a range,...
1. Write a C++ program, for.cpp, that reads three integers. The first two specify a range, call them bottom and top, and the other gives a step value. The program should print four sequences using for loops: Each value in the range from bottom to top Each value in the range from top to bottom, reverse counting Every second value in the range from bottom to top Every value from bottom to top increasing by step a: If bottom is...
Write a C program that reads three integers and then prints them in the order read...
Write a C program that reads three integers and then prints them in the order read and reversed. Use four functions: main, one to read the data, one to print them in the order read, and one to print them reversed.
Write a C++ program that reads integers from standard input until end of file. Print out...
Write a C++ program that reads integers from standard input until end of file. Print out the largest integer that you read in, on a line by itself. Any erroneous input (something that is not an integer) should be detected and ignored. In the case where no integers are provided at all, print NO INTEGERS and stop. The whole program is under 40 lines of code. Just read from cin. Now, you need to detect non integers. In this case,...
Write a C++ program that reads integers from standard input until end of file. Print out...
Write a C++ program that reads integers from standard input until end of file. Print out the largest integer that you read in, on a line by itself. Any erroneous input (something that is not an integer) should be detected and ignored. In the case where no integers are provided at all, print NO INTEGERS and stop. Remember, try not to do the entire job all at once! First try input of a single number and make sure it works....
Write a C++ program that reads integers from standard input until end of file. Print out...
Write a C++ program that reads integers from standard input until end of file. Print out the largest integer that you read in, on a line by itself. Any erroneous input (something that is not an integer) should be detected and ignored. In the case where no integers are provided at all, print NO INTEGERS and stop Remember, try not to do the entire job all at once! First try input of a single number and make sure it works....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT