answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

#define p printf

#define s scanf

int main()

{

clrscr();

int a,b,c,d,e;

int ans;

p("\nEnter first no.:");

s("%d",&a);

p("\nEnter second no.:");

s("%d",&b);

p("\nEnter third no.:");

s("%d",&c);

p("\nEnter fourth no.:");

s("%d",&d);

p("\nEnter fifth no.:");

s("%d",&e);

ans=(a+b+c+d+e)/5;

p("\nThe average is: %d",ans);

getch();

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

Here is a program capable of doing that:

#include <stdio.h>

#define MAX 5

int main() {

int ind, num, sum = 0;

for (ind = 0; ind < MAX; ind++) {

printf("Enter %d number: ", ind + 1);

scanf("%d", &num);

sum += num;

}

printf("Average of 5 numbers are %f\n", (float)sum / MAX);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

#include <iostream.h>

#include <conio.h>

void main()

{

float arr1[5], avg=0, sum=0;

cout<<"Enter 5 values for sum and average: "<<endl;

for(int i=0; i<5; i++)

{

cin>>arr1[i];

sum+=arr1[i];

}

avg=sum/5;

cout<<"Sum of 5 values is: "<<sum<<endl;

cout<<"Average of 5 values is: "<<avg;

getche();

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Start a loop

Ask for the user for a value

Add the value to a running sum

At end of loop, divide the running sum by 5 (or the total number of numbers entered by the user).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to read any five numbers and print average value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write the program in qbasic and add two numbers?

Cls input "enter two no.s ",a,b sum=a+b print "sum = ";sum end


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


Write a C Program to print sum of squares of odd numbers?

#include


Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.


How do you write a Qbasic program to display these Numbers-0112358132134?

you do this 10 print "0112358132134" use the whole of the thing


Write an assembly language program to print a to z on screen?

write a program to print A to Z on screen in c?


How do you write a program to print numbers from star one and next line star two in php?

Try the triangle program on a search engine. Replace numbers with stars and that should do the trick


Write a c program to print the 100 to 1 nos?

Write a c program to print the 100 to 1 nos


Write a unix program to print print a pattern?

echo 'print a pattern'


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


How do you Write a C program to print a Series of Odd Numbers and Even Numbers.?

Reference:http:cprogramming-bd.com/c_page2.aspx# strange number