Write a program to store marks obtained by 50 students.

Q.1 Write a program to store marks obtained by 50 students. Initialise the array having passed to a function initilise() having passed the array as parameter. Write another function which should take this array as parameter and return the highest score from the array. you have to write the proper function call, prototype and definition for each function.



THIS WAS MY QUESTION.

And this is the program which i wrote and got errors: -

#include<iostream.h>
#include<conio.h>
#define s 50

void init(int m[s]);
void display(int m[s]);
void find_max(int max, int m[s]);

void main()
{
clrscr();
int max;
cout<<"Welcome to my program: - ";
for(int i=0;i<s;i++)
init(m[i]);
for(i=0;i<s;i++)
display(m[i])
for(i=0;i<s;i++)
max=find_max(max,m[i])
cout<<max;
getch();
}
void init(int m[s])
{
cout<<"Enter the marks of 50 students: - ";
for(int i=0;i<s;i++)
cin>>m[i];
}
void display(int m[s])
{
cout<<"The marks of 50 students you have entered are : - ";
for(int i=0;i<s;i++)
cout<<m[i];
}
void find_max(int max, int m[i])
{
cout<<"The highest marks scored is: - ";
max = m[0];
for(int i=0;i<s;i++)
if(m[0]>max)
max=m[i];
else
cout<<max;
}




NOW PLEASE TELL ME WHAT IS THE ERROR AND FIX IT AND SEND ME BACK.
You have to declare variables before you try to use them OP. I don't even have to compile this to tell that you're getting (among others) something like "'m' was not declared in this scope" or something like that right?

Also, your declaration of the function "init()" expects an array but you're passing it a single element of an array in a for loop which isn't what your assignment is asking you to do.

Why do you appear to be trying to clear the console screen right off the bat? Do you know how annoying programs that do that are? Please don't fall into that habit.
Last edited on
Topic archived. No new replies allowed.