Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

another very very basic C assignment...

Status
Not open for further replies.

dck

Junior Member level 1
Joined
Aug 6, 2008
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,411
//Write a full program that reads user input of 10 scores and store them in an array.
//Next, calculate and display the total number of scores that are above the average score.

#include<stdio.h>

main()
{
int i, num=0,j;
double input[10], total=0, average;


for(i=0;i<10;i++)
{
printf("Plz enter input\n");
scanf("%lf", &input);
}
for(i=0;i<10;i++)
{
total=total+input;
}

printf("Total is %.2f\n", total);
average=total/10;
printf("\nAverage is %.2f\n", average);

for(j=0;j<10;j++)
{
if(input > average)
num++;
}
printf("Number of scores that above average is %d\n", num);

}




why isnt my program working??
i had spent hours over it...:cry:
 

check this: in the last for loop you are using index j but in if statement you are using i as index in input array. It shoud be like this:

for(j=0;j<10;j++)
{
if(input[j] > average)
num++;
}
 

    dck

    Points: 2
    Helpful Answer Positive Rating
I removed my reply because I was just echoing the previous posters reply.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top