C++ Programs

 
C++ Practical Assignment

Assignment-1


   1. Write a program to find out total and average of three subject marks.
2       2. Write a program to find square root of given number
3       3. Write a Program to find out Area of Circle Using const keyword.
4       4. Write a program to read the ten-element array from the keyboard and find maximum number from an array.
5       5. Write a program that prints the Fibonacci series upto given number.
6       6. Write a program that print the reverse of entered no.
7       7. Write a Program which calculate sum where
s = 1+2+3+………..n using
- For loop
- while loop
Do while loop


8        8. Write a program to enter five Elements in an array and print it in reverse Order.
9        9. Write a Program that uses the concept of Structure.
1        10. Write a Program that uses the Manipulator like endl, setw and setfill?
1        11. Write a Program of that uses the concepts of Enumeration (Enum)?

Assignment-2

  1. Write a program that interchange two values without using third variable. (Use call by value).
  2. Write a program that interchange two values without using third variable. (Use call by reference).
  3. Write a program that uses the concept of inline function.
  4. Write a Program of find out Simple Interest which takes a value of R (Rate of Interest) As Default Argument.
  5. Write a program that uses the concept of function overloading.

Assignment-3 classes and objects

  1. write a program to demonstrate the basic class program to get an employee’s no, name  and salary.
  2. Write a c++ program to demonstrate use of scope resolution operator. Use data given above.
  3. create a class student that has rollno,name,marks[3] as data member and void getinfo(void)and void putinfo(void)as member function.
  4. Write c++ program to demonstrate how private member functions can be accessed in a class.
  5. Write a c++ program that uses the concepts of array of objects.
  6. Write a c++ program that uses the concepts of object as arguments for the member function.
  7. Write a c++ program that uses the concepts of friend function.

Assignment -4 constructor

  1.  Create a class time that has hh,mm,ss as data members, create parameterized    constructor to initialize time Objects.
  2.   Write a c++ program to Count No. of objects with the help of constructor.
  3.  Write a c++ program that uses the concepts of copy constructor
  4.  Write a program demonstrates working of constructor & destructor in same class with static member.



Assignment no-5 Operator Overloadning

1.
Write a program of overloading unary operator with member functions?
2
.write a program of overloading unary operator with friend function.
3.
write a program to demostrate Binary operator with member function.
4.
write a program to demostrate Binary operator with friend function
5
.write program to illustrate basic to class type conversion.
6.
write program to illustrate class to basic type conversion.


  Assignment no-6 Inheritance

1.Write a c++ program to implement single Inheritance.
2. Write a c++ program to implement multiple Inheritance.
3. Write a c++ program to implement multilevel Inheritance.
4. Write a c++ program to implement Hierachical Inheritance.
5. Write a c++ program to implement hybrid Inheritance.
6. Write a c++ program that uses the concept of virtual base class.




==> A PROGRAM TO FIND THE AVERAGE OF THREE NO.S

#include<iostream.h>
#include<conio.h>
void main()
{
  int a,b,c,sum,ave;
  clrscr();
  cout<<"\n\n Enter sub1 marks a:";
  cin>>a;
  cout<<"\n\n Enter sub1 marks b:";
  cin>>b;
  cout<<"\n\n Enter sub1 marks c:";
  cin>>c;
  sum=a+b+c;
  cout<<"\n\n sum:"<<sum;
  ave=sum/3;
  cout<<"\n\n ave:"<<ave;
  getch();
}


==> A PROGRAM TO FIND THE SQRT OF GIVEN NO.

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
   int n,ans;
   clrscr();
   cout<<"\n\n Enter the value of n:";
   cin>>n;
   ans=sqrt(n);
   cout<<"\n\n the sqrt of given no.:"<<ans;
   getch();
}


==>CLASS PROGRAM TO GET EMPNO,NAME,SALARY.

#include<iostream.h>
#include<conio.h>
class emplo
{
int a,b;
char c[15];
float salary;
public:
void getdata()
{
cout<<"enter the emplooye no"<<endl;
cin>>a;
cout<<"enter the name"<<endl;
cin>>c;
cout<<"enter the emplo salary"<<endl;
cin>>b;
}
void show()
{
cout<<"employee no is"<<a<<endl;
cout<<"employee name is"<<c<<endl;
cout<<"employee salary is"<<b<<endl;
}
};
void main()
{
clrscr();
emplo a;
a.getdata();
a.show();

getch();
}

==> A PROGRAM FOR ADD.,SUB.,MULTI.,DIV.


#include<iostream.h>
#include<conio.h>
void add(void);
int sub(void);
int multi(int,int);
void div(int,int);
void main()
{
    int a=12,b=2;
    clrscr();
    add();
    sub();
    multi(a,b);
    div(a,b);
    getch();
}
void add(void)
{
    int a=10,b=5,c;
    c=a+b;
    cout<<"\n\n Addition:"<<c;
}
int sub(void)
{
    int a=10,b=3,c;
    c=a-b;
    cout<<"\n\n Substraction:"<<c;
    return 0;
}
int multi(int a,int b)
{
    int c;
    c=a*b;
    cout<<"\n\n Multiplication:"<<c;
    return 0;
}
void div(int a,int b)
{
   int c;
   c=a/b;
   cout<<"\n\n Division:"<<c;
}


==> A PROGRAM FOR SWAPPING TWO NO.S WITHOUT USING THIRD  NO.(call by value).

#include<iostream.h>
#include<conio.h>
void swap(int,int);
void main()
{
   int a,b;
   clrscr();
   cout<<"\n\n Enter the value of a:";
   cin>>a;
   cout<<"\n\n Enter the value of b:";
   cin>>b;
   cout<<"\n\n Before swapping the value of a="<<a<<"\tb="<<b;
   swap(a,b);
   getch();
}
void swap(int a,int b)
{
   a=a+b;
   b=a-b;
   a=a-b;
   cout<<"\n\n After swapping the value of a="<<a<<"\tb="<<b;
}

No comments: