hear out put of student mark only showing the last 2 marks for the both student.
#include%26lt;iostream.h%26gt;
#define n 2
#define m 2
#include%26lt;conio.h%26gt;
void main (void)
{
char name[20],regno[10];
int c,i;
int mark[m];
clrscr();
for(c=0;c%26lt;n;c++)
{
cout%26lt;%26lt;"\nstudent name :";cin%26gt;%26gt;name[c];
cout%26lt;%26lt;"\nstudent reg no :";cin%26gt;%26gt;regno[c];
for (i=0;i%26lt;2;i++)
{
cout%26lt;%26lt;"\nenter mark for subject"%26lt;%26lt;i+1%26lt;%26lt;" :"; cin%26gt;%26gt;mark[i];
}
}
for(c=0;c%26lt;n;c++)
{
cout%26lt;%26lt;"\nstudent name is :"%26lt;%26lt;name[c];
cout%26lt;%26lt;"\nstudent reg no is :"%26lt;%26lt;regno[c];
for (i=0;i%26lt;2;i++)
{
cout%26lt;%26lt;"\nmark for subject "%26lt;%26lt;i+1%26lt;%26lt;"is :"%26lt;%26lt;mark[i];
}
}
}
I have develop a ++ program .can some one check this one and let me know what was the error.?
remove the '[c]' in name[c] and regno[c] everywhere.
you don't need to put it for character arrays. It'll look like this:
#include%26lt;iostream.h%26gt;
#define n 2
#define m 2
#include%26lt;conio.h%26gt;
void main (void)
{
char name[20],regno[10];
int c,i;
int mark[m];
clrscr();
for(c=0;c%26lt;n;c++)
{
cout%26lt;%26lt;"\nstudent name :";
cin%26gt;%26gt;name;
cout%26lt;%26lt;"\nstudent reg no :";
cin%26gt;%26gt;regno;
for (i=0;i%26lt;2;i++)
{cout%26lt;%26lt;"\nenter mark for subject"%26lt;%26lt;i+1%26lt;%26lt;" :";
cin%26gt;%26gt;mark[i];
}
}
for(c=0;c%26lt;n;c++)
{
cout%26lt;%26lt;"\nstudent name is :"%26lt;%26lt;name;
cout%26lt;%26lt;"\nstudent reg no is :"%26lt;%26lt;regno;
for (i=0;i%26lt;2;i++)
{
cout%26lt;%26lt;"\nmark for subject "%26lt;%26lt;i+1%26lt;%26lt;"is :"%26lt;%26lt;mark[i];
}
}
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment