0

i have written a program taking marks of 35 students and calculating their average.can somebody please help me find my mistakes.the compiler is giving errors
errors:---------------------Configuration: t2 - Win32 Debug--------------------
Compiling...
t2.cpp
E:\coding\t2\t2.cpp(21) : error C2109: subscript requires array or pointer type
E:\coding\t2\t2.cpp(21) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
E:\coding\t2\t2.cpp(29) : error C2109: subscript requires array or pointer type
E:\coding\t2\t2.cpp(30) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
E:\coding\t2\t2.cpp(42) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.

--------------------------------------------------------------------------
code is as under:-

#include<iostream.h>
#include<conio.h>	
class student
{
private:
int marks,sum;
float average;

public:
/*	student()
	{
		marks[30];
		sum=0;
		average=0.0;
	}*/
	void enter_values()
	{
		cout<<"\nenter the marks of students one by one";
		for(int i=0;i<=35;i++)
		{
		cin>>marks[i];
		}
	}
	int calculate_average()
	{
		for(int j=0;j<=35;j++)
		sum+=marks[j];
		average=sum/35;
		cout<<"\naverage marks of students"<<average;
	}
};
int main()
{
	student s;
	s.enter_values();
	s.calculate_average();
}

help me rum the code.i really need help

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by Moschops
1

marks[30]; does not turn the int marks into an array. If you want marks to be an array, make it one when you declare it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.