- 2
Write a program that declares a structure to store roll no and marks of five subjects. It defines a structure variable, input...
Write a program that declares a structure to store roll no and marks of five subjects. It defines a structure variable, inputs the values and displays roll no, total marks and average marks.
6 Answers
+ 1
Here are some of the problems:
Array indexing begins at 0 and ends at size - 1. The valid range in your array of 5 students is [0 ... 4].
Your for-loop counter 'i' begins at 1 and continues if it's less than or equal to 5 - skipping the 0th element and writing past the end of the array.
Also, what is the purpose of int student[5] in the student struct?
+ 1
As Jegix stated "here are some of the problems"... meaning than making your code able to run probably don't correct widely its behavior, as you seems to mess up your task ^^
And as Benjamin JĂŒrgens stated "please indent your code properly"... as indention help to get better reading and understanding ;P
Anyway, here's my corrected version of your code, with what I've understood from your task:
https://code.sololearn.com/cGNDHsrHxakP/?ref=app
0
https://code.sololearn.com/cPu9WO39Prd0/?ref=app
0
So what's your question?
Sidenote: please indent your code properly
0
Benjamin JĂŒrgens It's not working.There is a problem in displaying all values of student details like all values remain same.
0
Thank You visph