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

31st Jan 2021, 2:54 PM
Arslanzafar Zafar
Arslanzafar Zafar - avatar
6 Réponses
+ 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?
31st Jan 2021, 4:18 PM
Mike A
Mike A - avatar
+ 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
31st Jan 2021, 7:04 PM
visph
visph - avatar
0
https://code.sololearn.com/cPu9WO39Prd0/?ref=app
31st Jan 2021, 3:28 PM
Arslanzafar Zafar
Arslanzafar Zafar - avatar
0
So what's your question? Sidenote: please indent your code properly
31st Jan 2021, 3:47 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Benjamin Jürgens It's not working.There is a problem in displaying all values of student details like all values remain same.
31st Jan 2021, 3:53 PM
Arslanzafar Zafar
Arslanzafar Zafar - avatar
0
Thank You visph
1st Feb 2021, 10:34 AM
Arslanzafar Zafar
Arslanzafar Zafar - avatar