Question

In: Computer Science

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.

Solutions

Expert Solution

#include <stdio.h>

void getData(int *a){

printf("Enter data: ");

scanf("%d", a);

}


void printDataOrder(int a, int b, int c){

printf("Inorder: %d %d %d\n", a,b,c);

}

void printDataReverseOrder(int a, int b, int c){

printf("Reverse: %d %d %d\n", c,b,a);

}

int main(void) {

int a, b , c;

getData(&a);

getData(&b);

getData(&c);

printDataOrder(a, b, c);

printDataReverseOrder(a, b, c);


return 0;

}

============================================================
SEE OUTPUT

========================================
Thanks, let me now if there is any concern.


Related Solutions

Write a C# program using repl.it that asks the user for three integers and prints the...
Write a C# program using repl.it that asks the user for three integers and prints the average value as a double. Example calculation (3 + 6 + 7) / 3 = 5.33333333333333 Given the data above, the output should be similar to: The average for the values entered is: 5.33333333333333 As always comments in your code are expected (what why how etc… ) Submit your repl.it link to the assignment dropbox text submission area.
Write a Java program that reads two integers on the keyboard and displays them on the...
Write a Java program that reads two integers on the keyboard and displays them on the screen.
Write a program that uses a while statement to read integers from the user and prints...
Write a program that uses a while statement to read integers from the user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters 999. The average should be output with 4 digits of precision. c++ please ASAP
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
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 a .img file by rows and columns and prints out...
Write a c program that reads a .img file by rows and columns and prints out the arrays. The .img file contains h(the height) and w(the width) of the text size. An example .img file would be: 2 4 DFJSK HJ5JF HFDY5
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...
(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.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT