9.11.14

OOP : Excercise-6 : Write a Object Oriented Program to Display Studnet Information

Create a class named as Student containing the following data members:
--Roll_no
--Name
--Marks1, Marks2, Marks3
Write necessary member functions:
1. to accept details of all students
2. to display details of one student
3. to display details of all students(Use Function overloading).
 (Use Function overloading)

OOP : Excercise-5 : Check Whether the given number is Strange or Not.

Note: Use Inheritance to solve this program.

//check strange number using inheritance
‪#‎include‬<iostream>
using namespace std;
//base class
class strange
{
public:
void setdigit(int d)
{
digit=d;
}
protected:
int digit;
};
//derived class
class number : public strange
{
public:
int i,j,t=1,d;
int devide()
{
while(d!=0)
{
j=d%10;
d=d/10;
for(i=2;i<j;i++)
{
if(j%i==0)
{
t=0;
i=j;
}
}
}
}
int check()
{
if(t==1)
cout<<"this number is strange";
else
cout<<"this number is not strange";
}
};
int main()
{
number nmb;
int a;
cin>>a;
nmb.setdigit(a);
nmb.check();
}

Function : Excercise-4.2 : Check Whether the given number is Strange or Not.

[Use user defined function to solve this problem]

#include<iostream>
using namespace std;
int chkstrange(int digit);
int main()
{
int digit,p;
cout<<"Enter Number to Check: ";
cin>>digit;
p= chkstrange(digit);
if (p==1) cout<<"strange";
else
cout<<"Not strange";
}
//function start here
int chkstrange(int digit)
{
int temp,rem,temp2=1;
while(digit!=0)
{
temp=digit/10;
rem=digit%10;
digit=temp;
for(int i=2;i<rem;i++)
    {
    if (rem%i ==0)
    {
    temp2= 0;
    i=rem;
    }
    }   
}
return temp2;
}