1. Write a program using one dimensional array that
calculates the sum and average of the five input values from
the keyboard and prints the calculated sum and average.

Answers were Sorted based on User's Feedback



1. Write a program using one dimensional array that calculates the sum and average of the five inpu..

Answer / sreejesh1987

#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum=0,a[4];
float av;
clrscr();
printf("\t\t\tSUM & AVERAGE\n");
printf("Enter Five numbers:");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
av=sum/5;

printf("\nOutput:\n\tSum:%d,Average:%.2f",sum,av);
getch();
}

Is This Answer Correct ?    57 Yes 33 No

1. Write a program using one dimensional array that calculates the sum and average of the five inpu..

Answer / mhaine mercado

#include<stdio.h>
main()
{
int i,n[5]
float sum,ave;

printf("\nEnter five numbers:");
for(i=0;i<5;i++)
{
scanf("%d",&n[i]);
}

sum=0;
for(i=0;i<5;i++){
sum=sum+n[i];
}
ave=sum/5;
printf("\nThe sum is: %f",sum);
printf("\nThe average is: %f",ave);

getch();
}

Is This Answer Correct ?    32 Yes 19 No

Post New Answer

More C++ Code Interview Questions

How do I store linked list datas into an array?

1 Answers  


Code for Two Classes for Doing Gzip in Memory?

0 Answers  


write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

0 Answers   HCL, SRCASW,


write a program to perform generic sort in arrays?

0 Answers  


void main() { int i,j=2; for(i=0;i<3;i++) if(j=i) cout<<"Lotus "; else cout<<"Rose "; } Its result is Rose Lotus Lotus.. How? Explain it?

2 Answers  






Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

0 Answers  


Ask the user to input three positive integers M, N and q. Make the 2 dimensional array of integers with size MxN, where all the elements of I (I = 1,…,M) line will be members of geometrical progression with first element equal to the number of line (I) and denominator q.

0 Answers  


Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.

0 Answers  


1+1/2!+1/3!+...+1/n!

0 Answers  


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

0 Answers  


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.

3 Answers   TCS, Vimukti Technologies, Wipro,


write a program that can locate elements in array.

1 Answers  


Categories