Jan 17, 2014 at 8:45am UTC
This is the program below..can you spot the errors in it.. I am getting lots of errors...!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student
{
char name[10];
int rollnumber,result
float m1,m2,m3,total
};
student sr[10];
void main()
{
clrscr();
int i,n
cout<<"Enter total number of students\n" ;
cin>>n;
for (i=0;i<n;i++)
{
cout<<"Enter Name\n" ;
gets(sr[i.name])
cout<<"Enter Roll Number\n" ;
cin>.(sr[i.rollnumber]);
cout<<"Enter marks in three subjects\n" ;
cin>>(sr[i.m1],sr[i.m2] ,sr[i.m3])
sr[i.total]=sr[i.m1]+sr[i.m2]+sr[i.m3];
}
cout<<"\t" "\t" <<Result is<<"\n" ;
cout<<"Name" <<"\t" <<rollnumber<<"\t" <<Total Marks<<"\n" ;
for (i=0;i<n;i++)
{
cout<<"sr[i.name]<<" \t"<<sr[i.rollnumber:]<<" \t"<<sr[i.total]<<" \n";
}
getch();
}
Last edited on Jan 17, 2014 at 9:03am UTC
Jan 17, 2014 at 9:03am UTC
What errors in particular?
I can see a lot of syntax problems involving missing or misplaced terminators (the ';' symbol). I'd start by fixing those.
Jan 17, 2014 at 9:28am UTC
yes, many such problems...but cant figure out....
are you able to edit that question itself...or will you post the answer?
Jan 17, 2014 at 9:41am UTC
I'm sort of getting the impression that this is some sort of 'make the code work' assignment that you might have been given.
I think it'd be best if you did it. :-)
Jan 17, 2014 at 10:03am UTC
dude dont tell me that....
why i posted it here...dont talk like a teacher..!!
Jan 17, 2014 at 10:16am UTC
I'm not talking like a teacher at all.
Looking at the code it looks like it could be some exercise that's been given for you to look at and produce a working version of the code. If that's the case, there is little point in my or anyone else on this forum doing it for you. There'd be no learning involved on your part.
Even if it's not this case and this is genuinely your code with errors then I think you need to refer to my second post. I gave you a reasonable starting point so you should at least attempt it yourself. Some of the errors there are pretty rudimentary, so if you can't spot those then I'd consider looking over some of the fundamentals. Where to put a terminator falls in this category.
Jan 17, 2014 at 10:34am UTC
OK, I ask you one by one teach me hows it done..!! Since you have said this much I am going to learn from you step by step :P
So be patient.!!
first
Error: Declaration missing ; for....... int rollnumber,result
is ; necessary after declaring integers
Last edited on Jan 17, 2014 at 10:34am UTC
Jan 17, 2014 at 10:51am UTC
Good. There are similar errors to that one for other variable declarations in there too.
Jan 17, 2014 at 11:17am UTC
haha..wait...now just 1 error :D
Jan 17, 2014 at 11:20am UTC
Excellent. :-)
What is it?
Jan 17, 2014 at 12:10pm UTC
Nothing now...
Fixed all....
Good that you made me itself do it, feels good..!!
But luckily I completed in time...!!! Hmmmmmmm