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

Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).

1 Answers   Infosys, Qatar University,


What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }

0 Answers  


Write a program using two-dimensional arrays that determines the highest and lowest of the 12 input values. Example: Enter 12 numbers: 13 15 20 13 35 40 16 18 20 18 20 14 highest: 40 lowest: 13

1 Answers  


A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE OUTPUT: E

1 Answers  


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

0 Answers  






a program using one dimensional array that searches a number if it is found on the list of given input numbers given by the user and locate its exact location in the list.. ""EXAMPLE"" enter how many numbers to be inputted: 5 12 14 11 09 30 what number to search: 11 11 IS FOUND IN LOCATION 3 PLZZZ.. ELP ME...

3 Answers  


hello friends, given an expression we have to remove the unwanted brackets in that expression. Eg : (a+b) ---> a+b (a+b)*(c)-----> (a+b)*c. Please mail me if you know the logic. My mail id is : saravana6m@gmail.com. Thank you in advance :-)

1 Answers   GrapeCity, Microsoft,


write a program that reverses the input number of n.Formulate an equation to come up with the answer.

0 Answers   Satyam,


#include<stdio.h> #include<conio.h> void main() { char str[10]; int,a,x,sw=0; clrscr(); printf("Enter a string:"); gets(str); for(x=0;x<=a;a++); for(x=0;x<=a;x++) { if(str[x]==str[a-1-x]) { sw=1; } else sw=0; } if(sw==10 printf("The entered string is palindrome:"); else printf("The entered string is not a palindrome:); } getch(); } wht would be the explanation with this written code???

2 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.

2 Answers   TCS,


can you please write a program for deadlock that can detect deadlock and to prevent deadlock.

0 Answers  


output for printf("printf");

0 Answers  


Categories