Structure in c++ :

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

Struct stud

{

                Int rno;

                Char nm[30];

                Float per;

 

                Void getdata()

                {

                                cout<<” enter roll Number=”;

                                cin>>rno;

cout<<” enter Name=”;

                                cin>>nm;

 

cout<<” enter Percentage=”;

                                cin>>per;

                }

                Void disp()

                {

                                Cout<<” Name=”<<nm<<” Roll No=”<<rno<<” Percentage=”<<per;

                }

 

 

};

Void main()

{

Struct stud s1,s2;

clrscr();

s1.getdata();

s2.getdata();

s1.disp();

s2.disp();

getch();

 

}

Class in c++ :

#include<iostream.h>

#include<conio.h>

Class A

{

                Private:

                                int a;

                                float b;

                public:

                                void getdata()

                                {

                                                cout<<” Enter a=”;

                                                cin>>a;

                                                cout<<” Enter b=”;

                                                cin>>b;

               

                                }

Void disp()

                                {

                                                cout<<” a=”<<a<<” b=”<<b;

                                }

}             

Void main()

{

                Clrscr();

                A a1;

                a1.getdata();

                a1.disp();

                getch();

 

}