Hi all,

I just joined the post. Iam new to C programming. I have a question regarding a problem i found in some book. The problem is i have a input file with student ID, 5 program scores, midterm and final score. i have to check for wrong input of data(negative score),calculate average score for program,calculate student totalscore (30% of programming,30% midterm,35%final and 5%free for whoever takes final exam),give grade to student and then finally compute calss total score.

print in a format (sID,sc1,sc2,sc3,sc4,sc5,midterm,final,total, grade) to the output file.

My idea looks very simple to the problem. I think it may not that simple as i think. Please guide me.

-First we have to scan the details from input file
-if the score is > 0 and < 100 then
1)calculate average score for programs (total all score and divide by 5)
2) student total score i.e 30%*total program score+35%midterm+35%*final+5%
Else
display "the score is not a valid one"
If Marks >=90 and <=100 then

Else if marks >= 80 and <=89 then

Else if marks >= 70 and <=79 then

Else if marks >= 60 and <=69 then

Else if marks >=0 and <=59 then

4) calculate total class score

Please let me know if iam right. If possible please tell me how to start writing C code for this or the pseudocode

All 6 Replies

Hmmm almost there.
You just need to change

if the score is > 0 and < 100 then

Why cant the score be 100 ?

Just loop through the scores, and at the same time check for the above condition, if not satisfied duck out of the program using "exit (1)" or just consdier the score as 0 and move on.

And to start off programming there are many basic tuts on the C language in the forum sticky at the top of C++ forum here.

Or if you know a bit of C just post what you can do and we will try to help you out.

You also don't need the range in the IF's. For example

``````IF score > 90   ; this will take everything above 90...
Display A   ; Output grade and the IF is over
else
IF score > 80   ; this will take everything above 80...
Display B   ; anything above 90 has already been taken care of above
else
...``````

Thanks for your reply. How do I calculate for all the 5 students and store their individual score and then total it up outside the loop? I think i need to store them in some variable. There is where i get stuck and cannot proceed further.

thanks

Thanks for your reply too. I did write a program like u said. But i don't want it to take value beyond 100 i.e 101 or 102..... so that is reason i put them in the range.

Thanks for your reply too. I did write a program like u said. But i don't want it to take value beyond 100 i.e 101 or 102..... so that is reason i put them in the range.

So your first IF is at 100 and you output an error.

Thanks for your reply. How do I calculate for all the 5 students and store their individual score and then total it up outside the loop? I think i need to store them in some variable. There is where i get stuck and cannot proceed further.

What do you know about arrays?

So your first IF is at 100 and you output an error.

What do you know about arrays?

Hi,

Thanks all for the help. I did finish writing my program this week

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.