学校のプロジェクトで Turbo C++ を使用しています。非常に古いもので、コード ブロックまたは MVC++ を使用する必要があることはわかっていますが、学校用の単純なプログラムに使用しているだけです。さて、私の問題は、char配列を出力できないことです。これが私の簡単なコードです
#include <iostream.h>
#include <conio.h>
class abc
{
private:
int rno,m1,m2,tot;
char sname[10],grade;
public:
void getinput()
{
cout<<"Enter roll no:"<<endl;
cin>>rno;
cout<<"\nEnter mark 1:"<<endl;
cin>>m1;
cout<<"\nEnter mark 2:"<<endl;
cin>>m2;
cout<<"\nEnter student name:"<<endl;
cin>>sname;
cout<<endl;
// Getting the returns.
//tot = gettotal();
//grade = getgrade();
}
void gettotal()
{
tot = m1+m2;
// Returning the total to getinput's "tot" part.
//return (tot);
}
void getgrade()
{
if(tot >= 150)
{
grade = 'A';
}
else if(tot >= 100)
{
grade = 'B';
}
else
{
grade = 'C';
}
// Returning the total to getinput's "grade" part.
//return (grade);
}
void display()
{
cout<<sname<<"'s total grade ranks: "<<grade;
}
};
void main()
{
abc a;
a.getinput();
a.gettotal();
a.getgrade();
a.display();
}
As you can see, it asks for marks 1 and marks 2 and then calculate it and prints 'A','B' and 'C' depending on marks.
Okay so what I want is to print 'First','Second' and 'Third' instead of A,B,C.
Can someone help me on this please.
Thanks.