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

3. Write a program which performs the following tasks: a. Reads three integers i

ID: 3721805 • Letter: 3

Question

3. Write a program which performs the following tasks:

a. Reads three integers interactively

b. Finds the sum of numbers

c. Finds the average of the numbers and

d. Print the sum and average of the numbers

Note : No function is required

4. Write a program which performs the following tasks

a. Reads three integers interactively(one at the time)

b. finds the sum of the numbers and

C. print the sum of the numbers              

       Note : The program should contain three functions . A function to read a number, a function to add         numbers and a function to find the sum of numbers.

5. Write an interactive program that performs the following tasks

a. Reads 5 integers into one dimensional array,

b. Finds the sum of the integers using a function. Functions should receive the array and return the sum,

c. Prints the sum of numbers using a function . Function should receive the sum and print it .   

Requirements : Develop a solution using a structure chart before you write codes.                                              

Explanation / Answer

3.

#include<stdio.h>
int main()
{
int a,b,c,sum,avg;  
printf(" Enter the three integer: ");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
avg=sum/3;
printf(" sum=%d",sum);
printf(" average=%d",avg);
return 0;
}

4. #include<stdio.h>
int sum=0;
int read()
{
int a;
printf(" Enter the number: ");
scanf("%d",&a);
return a;
}
void addnumber(int a)
{
sum=sum+a;
}
void findsum()
{
printf(" Sum=%d",sum);
}
int main()
{
int a,b,c;  
a=read();
b=read();
c=read();
addnumber(a);
addnumber(b);
addnumber(c);
findsum();
return 0;
}

5.

#include<stdio.h>
int sum=0;
int read()
{
int a;
printf(" Enter the element%d of array: ",sum+1);
scanf("%d",&a);
sum++;
return a;
}
void printsum(int a)
{
printf(" sum=%d",a);
}
int findsum(int a[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
sum+=a[i];
return sum;
}
int main()
{
int a[5],i,sum;  
for(i=0;i<5;i++)
a[i]=read();
sum=findsum(a,5);
printsum(sum);
return 0;
}

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