please do EXAM 3 PROGRAM 1 THEN After running the program, Paste the result or o
ID: 3757823 • Letter: P
Question
please do EXAM 3 PROGRAM 1 THEN After running the program, Paste the result or outcome and put it As comment in the program
Exam 3 Program 1: Write a C program which includes the following functions with parameter passing: hun Function 1: Allow the user to enter 4 integer values. Function 2: Print the 4 integer values. Function 3: Use the return statement to return the smallest of the 4 integer values. Print the smallest value in the main Function 4: Sort the 4 integer values from low to high. Upon returning to the main, use your print function to print the 4 integer values in sorted order. Exam 3 Program 2: Rewrite Exam 2 Program 1 using appropriate functions and parameter passing. Also, please include a structure chart for your program which you can either create by hand or on the computer. SOExplanation / Answer
#include <stdio.h>
void input(int* arr,int size){
int i = 0;
for(i = 0; i < size; i++)
scanf("%d",&arr[i]);
}
void print(int* arr,int size){
int i = 0;
for(i = 0; i < size; i++)
printf("%d ",arr[i]);
printf(" ");
}
void sort(int* arr,int size){
int i,j;
int temp;
for(i = 0; i < size; i++){
for(j = i+1; j < size; j++){
if(arr[i] > arr[j]){
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
}
int main(){
int arr[4];
input(arr,4);
print(arr,4);
sort(arr,4);
print(arr,4);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.