C Program to find Sum and Average of Numbers.

In this program we learn to print Sum and Average of entered input(numbers) by user.

 

Let’s write a program which print the Sum and Average of n numbers.

 

Step 1: Let’s open turbo C and write the following Code.

 

// Add preprocessor

#include<stdio.h>

#include<conio.h>

void main()

{

float i=0;sum=0;

float a[10];

float avg=0;

 

// Clear screen

clrscr();

 

printf(“enter all numbers :”);

for(i=0;i<10;i++)

{

scanf(“%f”,&a[i]);

}

for(i=0;i<10;i++)

{

sum=sum+a[i];

}

avg=sum/i;

printf(“\n Sum=%f”,sum);

printf(“\n Average=%f”,avg);

getch();

}

 

 

Step 2: Run the program and see Output.

 

 

Output:

 

 

output

 

Happy coding.

 

Tags: , ,