Class 11 Practical Exercise for Reduced Syllabus

 CS1 - GROSS SALARY
CS-1
Write a C++ program to input basic salary of an employee and calculate its Gross salary according to following:
Basic Salary <25000 : HRA = 20%, DA = 80%
Basic Salary >= 25000 : HRA = 25%, DA = 90%
Basic Salary >= 40000 : HRA = 30%, DA = 95%
# include<iostream>
using namespace std;
int main()
{
float basic, gross, da, hra;
cout<<"Enter basic salary of an employee:";
cin>>basic;
if(basic<25000)
{
da=basic*80/100;
hra=basic*20/100;
}
else if(basic>=25000 && basic<40000)
{
da=basic*90/100;
hra=basic*25/100;
}
else if(basic>=40000)
{
da=basic*90/100;
hra=basic*30/100;
}
gross=basic+da+hra;
cout<<"\n\t Basic Pay.............."<<basic<<endl;
cout<<"\n\t Dearness Allowance....."<<da<<endl;
cout<<"\n\t House rent Allowance..."<<hra<<endl;
cout<<"\n\t Gross salary..........."<<gross<<endl;

}



CS2 - PERCENTAGE
CS-2
Write a C++ program to check percentage of a student and display the division (distinction, first, second, third or fail) scored using switch case
Percentage Division
>=80 Distinction
>=60 and <80 First division
>=50 and <60 Second Division
>=40 and <50 Third Division
<40 Fail

# include<iostream>
using namespace std;
int main()
{
float percent;
int x;
cout<<"Enter your percentage:";
cin>>percent;
cout<<"You scored"<<percent<<"%"<<endl;
x=percent/10;
switch(x)
{
case 10:
case 9:
case 8: cout<<"You have passed with Distinction";break;
case 7:
case 6: cout<<"You have passed with First division";break;
case 5: cout<<"You have passed with Second division";break;
case 4: cout<<"You have passed with Third division";break;
default: cout<<"Sorry:You have failed"; 
}
}


CS3 - PALINDROME
CS-3
Write a C++ program to enter any number and check whether the number is palindrome or not using while loop.

# include<iostream>
using namespace std;
int main()
{
int n,num,digit,rev=0;
cout<<"Enter a positive number";
cin>>num;
n=num;
while(num)
{
digit=num%10;
rev=(rev*10)+digit;
num=num/10;
}
cout<<"The reverse of the number is:"<<rev<<endl;
if(n==rev)
cout<<"The number is a Palindrome";
else
cout<<"The number is not a Palindrome";
return 0;
}




CS4 - NUMBER CONVERSION

CS-4
Using do while loop create the following menu based C++ program

# include<iostream>
# include<math.h>
using namespace std;
int main()
{
int dec,d,i,temp,ch;
long int bin;
do{
dec=bin=d=i=0;
cout<<"\n\n\t\t MENU\n1. Decimal to Binary number\n2. Binary to Decimal number\n3. Exit\n";
cout<<"Enter your choice(1/2/3)";
cin>>ch;
switch(ch)
{
case 1: cout<<"Enter a decimal number:";
cin>>dec;
temp=dec;
while(dec!=0)
{
d=dec%2;
bin+=d*pow(10,i);
dec/=2;
i++;
}
cout<<temp<<" in decimal= "<<bin<<" in binary"<<endl;
break;
case 2:
cout<<"Enter a binary number:";
cin>>bin;
temp=bin;
while(bin!=0)
{
d=bin%10;
dec+=d*pow(2,i);
bin/=10;
i++;
}
cout<<temp<<" in binary= "<<dec<<" in decimal"<<endl;
break;
default: cout<<"Invalid choice";
}
}while(ch!=3);
return 0;
}



CS5 - FIBONACCI PRIME SERIES

CS-5
Write a C++ program using a user defined function to generate the Fibonacci series till n terms and print if each term is prime or Composite.

# include<iostream>
# include<stdlib.h>
using namespace std;
void primechk(int a)
{
int j;
if(a==0 || a==1)
{
cout<<"Neither Prime Nor Composite";
}
else
{
for(j=2;j<a;j++)
{
if(a%j==0)
{
cout<<"\t composite";
break;
}
}
if(a==j)
{
cout<<"\t Prime";
}
}
}
void fibo(int n)
{
int a=-1,b=1,c=0;
for(int i=1;i<=n;i++)
{
cout<<endl;
c=a+b;
cout<<c;
primechk(c);
a=b;
b=c;
}
}
int main()
{
int n;
cout<<"Enter the number of required Fibo terms:";
cin>>n;
cout<<"\n\t Fibonacci series\n";
fibo(n);
return 0;
}




No comments:

Post a Comment