Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

These question correlate to C language. Any answers are appreciated. (Please if

ID: 3791119 • Letter: T

Question

These question correlate to C language. Any answers are appreciated. (Please if its handwritten write neatly )

Write a program to call a function changing mph into m/s. You need to type in the speed when running the functional mile = 1.6 km = 1600m) Write a program that when you type in five numbers, it will print the number from the smallest one to the largest one.(if you type in 2, 1, 3, 5, 4, the output will be 1, 2, 3, 4, 5) You may need more than one function to complete this mission. Initialize the elements of array S to the even integers from 10 to 40 and calculate the average of the elements. Print out every element smaller than 40 of array A [5, 16, 87, 65, 4, 32, 11, 108, 10, 25, 12, 27, 56, 38].

Explanation / Answer

Problem 1:

#include<stdio.h>

float convert(float input);

int main()
{
printf("type the speed(mph)");
float input;
scanf("%f",&input);
input=convert(input);
printf("%f",input);
}


float convert(float input)
{
input=(input*1600)/3600;
return input;
}

Problem 2:

#include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b)
{
return ( *(double*)a - *(double*)b );
}

int main()
{
double arr[5];
int i=0;
scanf("%lf,%lf,%lf,%lf,%lf",&arr[0],&arr[1],&arr[2],&arr[3],&arr[4]);


qsort(arr, 5, sizeof(double), cmpfunc);

printf(" After sorting the list is: ");
int n=0;
for( n = 0 ; n < 5; n++ )
{
printf("%lf ", arr[n]);
}
}

Problem 3:

#include<stdio.h>
#include<stdlib.h>


int main()
{
int i=0;
int s[16];
int j=0;
for(i=10;i<=40;i=i+2)
{
s[j]=i;
j++;
}
double avg=0;
for(i=0;i<16;i++)
{
avg=avg+s[i];
}
avg=avg/16;
printf("%lf",avg);
}

Problem 4:

#include<stdio.h>


int main()
{
int s[]={5,16,87,65,4,32,11,108,10,25,12,27,56,38};
int n=sizeof(s)/sizeof(s[0]);
int i=0;
for(i=0;i<n;i++)
{
if(s[i]<40)
{
printf("%d",s[i]);
printf(" ");
}
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote