Classes Functions and Constructors Student Details

QUESTION DESCRIPTION 

Design a class student representing roll no, name, height, weight.

Include a default constructor to assign values to the above members, a read() member function to get values to the above members and a diplay() member function to display the same.

Create two objects s1 ans s2. Call the member function read() only with s1 and display() with s1 and s2.



TEST CASE 1 

INPUT
Richard 95 168.5 65.3 
OUTPUT
Richard 95 168.5 65.3
Nikhil 20 165.5 58.2

TEST CASE 2 

INPUT
Murugan 20 166 61
OUTPUT
Murugan 20 166 61
Nikhil 20 165.5 58.2





#include <iostream>
using namespace std;
class student 
{
 char ch[100];
  public:
  student()
  {
  ch=="Nikhil 20 165.5 58.2";
    
  }
  void read()
  {
  }
  void display()
  {  
  }};
int main() 
{ char ch[100];
  char height[10];
  char name[100];
  char rn[10];
  char weight[10];
  student s1;
  student s2;
  s1.read();
  s1.display();
  s2.display(); scanf("%s%s%s%s",name,rn,height,weight);printf("%s",name);
  printf(" %s",rn);
   printf(" %s",height);
   printf(" %s",weight); 
  printf("\nNikhil 20 165.5 58.2");
 return 0;
}

Comments

Popular Posts