CS – 1 GROSS SALARY -------------
Gross Salary : 53750
#include<iostream> -------------
#include<iomanip> CS – 2 PERCENTAGE
using namespace std;
int main() #include<iostream>
{ using namespace std;
float basic, gross, da, hra; int main()
cout<<"\nEnter basic salary of an employee : "; {
cin>>basic; float percent;
if(basic<25000) int x;
{ cout<<"Enter your Percentage : ";
da=basic*80/100; cin>>percent;
hra=basic*20/100; cout<<"You scored : "<<percent<<"%"<<endl;
} x=percent/10;
else if(basic>=25000 && basic<40000) switch(x)
{ {
da=basic*90/100; case 10:
hra=basic*25/100; case 9:
} case 8:
else if(basic>=40000) cout<<"You have passed with Distinction";
{ break;
da=basic*95/100; case 7:
hra=basic*30/100; case 6:
} cout<<"You have passed with First division";
gross=basic+hra+da; break;
cout<<setw(30)<<"Basic Pay : "<<setw(8)<<basic<<endl; case 5:
cout<<setw(30)<<"Dearness Allowance : "<<setw(8)<<da<<endl; cout<<"You have passed with Second division";
cout<<setw(30)<<"House Rent Allowance : "<<setw(8)<<hra<<endl; break;
cout<<"\t\t"<<setw(25)<<"-------------"<<endl; case 4:
cout<<setw(30)<<"Gross Salary : "<<setw(8)<<gross<<endl; cout<<"You have passed with Third division";
cout<<"\t\t"<<setw(25)<<"-------------"<<endl; break;
return 0; default:
} cout<<"Sorry: You have Failed";
}
OUTPUT return 0;
}
Enter basic salary of an employee : 25000
Basic Pay : 25000 OUTPUT 1
Dearness Allowance : 22500 Enter your Percentage : 79
House Rent Allowance : 6250 You scored : 79%
You have passed with First division
OUTPUT 2 CS – 4 NUMBER CONVERSION
#include<iostream>
Enter your Percentage : 39 #include<cmath>
You scored : 39% using namespace std;
Sorry: You have Failed int main()
CS – 3 PALINDROME {
int dec, d, i, temp, ch;
#include<iostream> long int bin;
using namespace std; do
int main() {
{ dec=bin=d=i=0;
int n, num, digit, rev=0; cout<<"\n\t Menu";
cout<<"Enter a positive number : "; cout<<"\n\t ****";
cin>>num; cout<<"\n 1. Decimal to Binary Number";
n=num; cout<<"\n 2. Binary to Decimal Number";
while(num) cout<<"\n 3. Exit";
{ cout<<"\n\nEnter Your Choice (1 or 2 or 3) : ";
digit=num%10; cin>>ch;
rev=(rev*10)+digit; switch(ch)
num=num/10; {
} case 1:
cout<<"The Reverse of the number is : "<<rev<<endl; cout<<"\nEnter a Decimal number : ";
if(n==rev) cin>>dec;
cout<<"The Number is Palindrome"; temp=dec;
else while(dec!=0)
cout<<"The Number is not Palindrome"; {
return 0; d=dec%2;
} bin+=d*pow(10,i);
OUTPUT 1 dec/=2;
i++;
Enter a positive number : 1234 }
The Reverse of the number is : 4321 cout<<temp<<" in Decimal = "<<bin<<" in Binary"<<endl;
The Number is not Palindrome break;
case 2:
OUTPUT 2 cout<<"\nEnter a Binary Number : ";
Enter a positive number : 1221 cin>>bin;
The Reverse of the number is : 1221 temp=bin;
The Number is Palindrome while(bin!=0)
{
d=bin%10;
dec+=d*pow(2,i);
bin/=10; CS – 5 FIBONACCI PRIME SERIES
i++; #include<iostream>
} #include<stdlib.h>
cout<<temp<<" in Binary = "<<dec<<" in Decimal"<<endl; using namespace std;
break; void primechk(int a)
case 3: break; {
default: cout<<"Invalid Choice"; int j;
} if(a==0||a==1)
}while(ch!=3); cout<<"\tNeither Prime nor Composite\n";
return 0; else
} {
for(j=2;j<a;j++)
OUTPUT 1 OUTPUT 2 {
Menu Menu if(a%j==0)
**** **** {
1. Decimal to Binary Number 1. Decimal to Binary Number cout<<"\t Composite\n";
2. Binary to Decimal Number 2. Binary to Decimal Number break;
3. Exit 3. Exit }
}
Enter Your Choice (1 or 2 or 3) : 1 Enter Your Choice (1 or 2 or 3) : 4 if(a==j)
Invalid Choice cout<<"\tPrime\n";
Enter a Decimal number : 23
}
23 in Decimal = 10111 in Binary
Menu }
Menu **** void fibo(int n)
**** 1. Decimal to Binary Number {
1. Decimal to Binary Number 2. Binary to Decimal Number int a=-1, b=1, c=0;
2. Binary to Decimal Number 3. Exit for(int i=1;i<=n;i++)
3. Exit {
Enter Your Choice (1 or 2 or 3) : 2 Enter Your Choice (1 or 2 or 3) : 3 cout<<endl;
c=a+b;
Enter a Binary Number : 11001 cout<<c;
11001 in Binary = 25 in Decimal primechk(c);
a=b;
Menu
b=c;
****
}
1. Decimal to Binary Number
}
2. Binary to Decimal Number
int main()
3. Exit
{
Enter Your Choice (1 or 2 or 3) : 3 int n;
cout<<"Enter the number of required Fibo terms : " ;
cin>>n;
cout<<"\tFibonacci Series\n"; cout<<"-------------------\n";
fibo(n); cout<<"\nEnter your choice : ";
return 0; cin>>choice;
} switch(choice)
OUTPUT {
case 1: insert();
Enter the number of required Fibo terms : 10 break;
Fibonacci Series case 2: del();
0 Neither Prime nor Composite break;
1 Neither Prime nor Composite case 3: break;
1 Neither Prime nor Composite default: cout<<"\nInvalid choice";
2 Prime }
3 Prime } while(choice!=3);
5 Prime return 0;
8 Composite }
13 Prime void display()
21 Composite {
34 Composite int i;
cout<<"\nThe array elements are:\n";
CS – 6 INSERT / DELETE ELEMENTS IN AN ARRAY for(i=0;i<n;i++)
#include<iostream> cout<<a[i]<<" ";
using namespace std; }
int a[20],b[20],c[40]; void insert()
int m, n, p, val, i, j, key, pos, temp; {
void display(); cout<<"\nEnter the position for the new element : ";
void insert(); cin>>pos;
void del(); cout<<"\nEnter the element to be inserted : ";
int main() cin>>val;
{ for(i=n;i>=pos-1;i--)
int choice; a[i+1]=a[i];
cout<<"\nEnter the size of the array elements : "; a[pos-1]=val;
cin>>n; n=n+1;
cout<<"\nEnter the elements for the array : "; display();
for(i=0;i<n;i++) }
cin>>a[i]; void del()
do {
{ cout<<"\nEnter the position of the element to be deleted : ";
cout<<"\n--------Menu-------\n"; cin>>pos;
cout<<"1.Insert\n"; val=a[pos-1];
cout<<"2.Delete\n"; for(i=pos;i<n;i++)
cout<<"3.Exit\n"; a[i-1]=a[i];
n=n-1; CS – 7 BOUNDARY ELEMENT OF A MATRIX
cout<<"\nThe deleted element is = "<<val;
display(); #include<iostream>
} using namespace std;
OUTPUT void printBoundary (int a[][10], int m, int n)
{
Enter the size of the array elements : 5 for (int i = 0; i < m; i++)
Enter the elements for the array : {
1 for (int j = 0; j < n; j++)
2 {
3 if (i==0||j==0||i==m-1||j==n-1)
4 cout<<a[i][j]<<" ";
5 else
--------Menu------- cout<<" ";
1.Insert }
2.Delete cout<<endl;
3.Exit }
------------------- }
Enter your choice : 1 int main()
Enter the position for the new element : 3 {
Enter the element to be inserted : 26 int a[10][10], i, j, m, n;
cout<<"Enter more than 3 number of rows and columns : ";
The array elements are: cin>>m>>n;
1 2 26 3 4 5 for (i = 0; i < m; i++)
--------Menu------- {
1.Insert for (j = 0; j < n; j++)
2.Delete {
3.Exit cout<<"Enter the value for array ["<<i+1<<"] "<<"["<<j+1<<"] : ";
------------------- cin>>a[i][j];
Enter your choice : 2 }
Enter the position of the element to be deleted : 2 }
The deleted element is = 2 system("cls");
cout<<"\n\nOriginal Array\n";
The array elements are: for (i = 0; i < m; i++)
1 26 3 4 5 {
--------Menu------- for (j = 0; j < n; j++)
1.Insert {
2.Delete cout<<a[i][j]<<" ";
3.Exit }
------------------- cout<<endl;
Enter your choice : 3 }
cout<<"\n\nThe Boundary element\n"; int id=1001;
printBoundary(a, m, n); class Publisher
return 0; {
} int Bookno;
char Title[20];
OUTPUT char Author[10];
float Price;
Enter more than 3 number of rows and columns : float Totamt;
4 4 float calculate(int);
Enter the value for array [1] [1] : 1 public:
Enter the value for array [1] [2] : 2 Publisher()
Enter the value for array [1] [3] : 3 {
Enter the value for array [1] [4] : 4 Bookno=id;
Enter the value for array [2] [1] : 5 Title[0]='\0';
Enter the value for array [2] [2] : 6 Author[0]='\0';
Enter the value for array [2] [3] : 7 Price=0;
Enter the value for array [2] [4] : 8 Totamt=0;
Enter the value for array [3] [1] : 9 id++;
Enter the value for array [3] [2] : 0 }
Enter the value for array [3] [3] : 1 void Readdata();
Enter the value for array [3] [4] : 2 void Displaydata();
Enter the value for array [4] [1] : 3 };
Enter the value for array [4] [2] : 4 void Publisher::Readdata()
Enter the value for array [4] [3] : 5 {
Enter the value for array [4] [4] : 6 int nocopies;
cout<<"\nEnter the Title name : ";
Original Array cin>>Title;
1234 cout<<"Enter the Author name : ";
5678 cin>>Author;
9012 cout<<"Enter the Price : ";
3456 cin>>Price;
The Boundary element cout<<"Enter the Number of copies : ";
1 2 3 4 cin>>nocopies;
5 8 Totamt=calculate(nocopies);
9 2 }
3 4 5 6 float Publisher::calculate(int x)
{
CS – 8 ABC PUBLISHERS return x*Price;
#include<iostream> }
#include<stdlib.h>
using namespace std;
void Publisher::Displaydata() ABC PUBLISHERS
{ ~~~ ~~~~~~~~~~
cout<<"\n\tABC PUBLISHERS\n"; INVOICE
cout<<"\t~~~ ~~~~~~~~~~\n"; ~~~~~~~
==================================
cout<<"\tINVOICE\n";
Book Number : 1001
cout<<"\t~~~~~~~\n";
Title : C++
cout<<"\n==================================\n";
Author Name : Balaguru
cout<<" Book Number : "<<Bookno<<endl;
Price Per Book : 500
cout<<" Title : "<<Title<<endl;
Total Amount : 1500
cout<<" Author Name : "<<Author<<endl; ==================================
cout<<" Price Per Book : "<<Price<<endl; ABC PUBLISHERS
cout<<" Total Amount : "<<Totamt<<endl; ~~~ ~~~~~~~~~~
cout<<"\n==================================\n"; INVOICE
} ~~~~~~~
int main() ==================================
{ Book Number : 1002
int n, i; Title : Java
Publisher p[10]; Author Name : Xavier
cout<<"Enter the number of object to be created : "; Price Per Book : 250
cin>>n; Total Amount : 1250
for(i=0;i<n;i++)
p[i].Readdata(); ==================================
for(i=0;i<n;i++) CS – 9 EMPLOYEE DETAILS USING CLASS
p[i].Displaydata();
#include<iostream>
return 0;
#include<iomanip>
}
using namespace std;
class emp
OUTPUT
{
public:
Enter the number of object to be created : 2
int eno;
Enter the Title name : C++ char name[25], des[25];
Enter the Author name : Balaguru void get()
Enter the Price : 500 {
Enter the Number of copies : 3 cout<<"\nEnter the employee number : ";
cin>>eno;
Enter the Title name : Java cout<<"Enter the employee name : ";
Enter the Author name : Xavier cin>>name;
Enter the Price : 250 cout<<"Enter the designation : ";
Enter the Number of copies : 5 cin>>des;
}
};
class salary:public emp for (i =0; i < n; i++)
{ {
float bp, hra, da, pf, np; s[i].display();
public: }
void get1() return 0;
{ }
cout<<"Enter the basic pay : ";
cin>>bp; OUTPUT
cout<<"Enter the House Rent Allowance : "; Enter the number of employee : 2
cin>>hra;
cout<<"Enter the Dearness Allowance : "; Enter the employee number : 1201
cin>>da; Enter the employee name : Ram
cout<<"Enter the Provident Fund : "; Enter the designation : Tech
cin>>pf; Enter the basic pay : 50000
} Enter the House Rent Allowance : 10000
void calculate() Enter the Dearness Allowance : 5000
{ Enter the Provident Fund : 1000
np=bp+hra+da-pf;
} Enter the employee number : 1202
void display() Enter the employee name : Anu
{ Enter the designation : Engineer
Enter the basic pay : 40000
cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<< Enter the House Rent Allowance : 9000
da<<"\t"<<pf<<"\t"<<np<<"\n"; Enter the Dearness Allowance : 4500
} Enter the Provident Fund : 1000
};
int main() Employee Details
{ *********** ********
int i, n; E.No E-Name Des BP HRA DA PF NP
char ch; salary s[10]; 1201 Ram Tech 50000 10000 5000 1000 64000
cout<<"Enter the number of employee : "; 1202 Anu Engineer 40000 9000 4500 1000 52500
cin>>n;
for (i =0; i < n; i++) CS – 10 STUDENT DETAILS
{
s[i].get(); #include<iostream>
s[i].get1(); #include<iomanip>
s[i].calculate(); using namespace std;
} class Student
cout<<"\n\t\t\tEmployee Details\n"; {
cout<<"\n\t\t\t******** *******\n"; protected:
cout<<"\n E.No \t E-Name \t Des \t BP \t HRA \t DA \t PF \t NP \n"; int Rno;
public: };
void Readno(int r) class Result :public Test,public Sports
{ {
Rno=r; int Total;
} public:
void Writeno() void display()
{ {
cout<<"\nRoll no : "<<Rno; Total = Mark1 + Mark2 + score;
} Writeno();
}; Writemark();
class Test :public Student Writescore();
{ cout<<"Total Marks Obtained : "<<Total<<endl;
protected: }
float Mark1,Mark2; };
public: int main()
void Readmark (float m1,float m2) {
{ Result stud1;
Mark1=m1; stud1.Readno(1201);
Mark2=m2; stud1.Readmark(93.5,95);
} stud1.Readscore(80);
void Writemark() cout<<"\n\t\t\t HYBRID INHERITANCE PROGRAM";
{ cout<<"\n\t\t\t ****** *********** *******\n";
cout<<"\n\n\tMarks Obtained"; stud1.display();
cout<<"\n\t***** ********\n\n"; return 0;
cout<<"Mark1 : "<<Mark1<<endl; }
cout<<"Mark2 : "<<Mark2<<endl;
} OUTPUT
};
class Sports HYBRID INHERITANCE PROGRAM
{ ********* ***************** ************
protected: Roll no : 1201
int score; Marks Obtained
public: ******* **********
void Readscore (int s) Mark1 : 93.5
{ Mark2 : 95
score=s; Sports Score : 80
} Total Marks Obtained : 268
void Writescore()
{
cout<<"Sports Score : "<<score<<endl;
}