0% found this document useful (0 votes)
19 views5 pages

namma_kalvi_std_11_comp_pract_short

The document contains multiple C++ programming tasks, including calculating gross salary based on basic salary, determining student division based on percentage, checking if a number is a palindrome, converting between decimal and binary numbers, and generating Fibonacci series while identifying prime and composite numbers. Each task provides code snippets and logic for implementation. The content is structured as a series of programming exercises for educational purposes.

Uploaded by

Cecilia Atlas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

namma_kalvi_std_11_comp_pract_short

The document contains multiple C++ programming tasks, including calculating gross salary based on basic salary, determining student division based on percentage, checking if a number is a palindrome, converting between decimal and binary numbers, and generating Fibonacci series while identifying prime and composite numbers. Each task provides code snippets and logic for implementation. The content is structured as a series of programming exercises for educational purposes.

Uploaded by

Cecilia Atlas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

www.asiriyar.

net

da=basic*80/100;
hra=basic*20/100;
}
else if(basic<40000)
{
da=basic*90/100;
hra=basic*25/100;
}

et
else

.n
{
da=basic*95/100;

ar
hra=basic*30/100;
1. Write a C++ program to input basic salary of an
}
employee and calculate its Gross

riy
salary according to following: gross=basic+hra+da;
Basic Salary <25000 : HRA = 20%, DA = 80% cout<<"\nBasic Pay= "<<basic;
Basic Salary >= 25000 : HRA = 25%, DA = 90% cout<<"\nDearness Allowance= "<<da;

si
Basic Salary >= 40000 : HRA = 30%, DA = 95% cout<<"\nHouse Rent Allowance= "<<hra;
cout<<"\nGross Salary= "<<gross;
.a }
return 0;
w
#include<iostream>
w

using namespace std;


w

int main()
{
float basic,gross,da,hra;
cout<<"Enter Basic Salary:";
cin>>basic;
if(basic<25000) 22.22
{

www.tnschoolvideos.blogspot.in www.tnmanavan.blogspot.com
www.asiriyar.net

22 Write a C++ program to check percentage of a student case 7:


and display the division( distinction, first, second, third or case 6:
fail) scored using switch case cout<<"\nFirst Division";
Percentage Division
break;
>=80 Distinction
>=60 and <80 First division case 5:
>=50 and <60 Second Division cout<<"\nSecond Division";
>=40 and <50 Third Division break;
<40 Fail case 4:

et
cout<<"\nThird division";

.n
break;
default:

ar
cout<<"\nFailed";
#include<iostream> }return 0;

riy
using namespace std; }
int main()
{

si
float p;
int x;
cout<<"Enter your percentage:";
.a
w
cin>>p;
w

x=p/10;
switch(x)
w

{
case 10:
case 9:
case 8:
cout<<"\nDistinction";
break;

www.tnschoolvideos.blogspot.in www.tnmanavan.blogspot.com
www.asiriyar.net

3. CS-3 Write a C++ program to enter any number and


check whether the number is palindrome or not using while
loop.

4. CS-4 Using do while loop create the following menu


#include<iostream> based C++ program
using namespace std; 1.Convert a Decimal to binary number
int main() 2.Convert a binary number to Decimal

et
{ 3. Exit
int n,num,digit,rev=0; Depending on the choice accept the value and display the result

.n
cout<<"Enter a Number:"; .The program should continue till the user select the third
option
cin>>num;

ar
n=num;
while(num)

riy
{
#include <iostream>
digit=num%10;
#include <cmath>

si
rev=(rev*10)+digit;
using namespace std;
num=num/10;
int main()
}
cout<<"Reverse Number:"<<rev<<endl;
.a {
w
int dec,d,i,temp,ch;
if(n==rev)
long int bin;
cout<<"PALINDROME";
w

do
else
{
w

cout<<"NOT PALINDROME";
dec=bin=d=i=0;
return 0;
cout<<"MENU";
}
cout<<"\n 1. Decimal to Binary number";
cout<<"\n 2.Binary to Decimal number";
cout<<"\n 3.Exit\n";
cout <<"Enter your choice(1/2/3)";

www.tnschoolvideos.blogspot.in www.tnmanavan.blogspot.com
www.asiriyar.net

cin>>ch; cout<<"Invalid choice";


switch (ch) }
{ }
case 1: while (ch!=3);
cout << "Enter a decimal number: "; return 0;
cin >> dec; }
temp=dec;
while (dec!=0)

et
{

.n
d = dec%2;
bin += d * pow(10,i);

ar
dec /= 2; i++;
}

riy
cout << “\n Binary Num = “ << bin << endl ;
break;
case 2: cout << "Enter a binary number: ";

si
cin >> bin;
temp=bin;
while (bin!=0)
{
.a
w
d = bin%10;
w

dec += d*pow(2,i);
bin /= 10; i++;
w

}
cout << "\n Decimal num = "<<dec <<endl;
break;
case 3:
break;
default :

www.tnschoolvideos.blogspot.in www.tnmanavan.blogspot.com
www.asiriyar.net

5. CS-5 Write a C++ program using a user defined function int a = -1 , b = 1 ,c=0 ;
to generate the Fibonacci series till n terms and print if for ( int i = 1 ; i <= n ; i++)
each term is prime or Composite. {
cout<<endl;
c=a+b;
cout<<c;
#include <iostream>
Primechk(c);
#include <stdlib.h>
a = b; b = c ;

et
using namespace std;
}
void Primechk (int a )

.n
}
{
int main ()
int j;

ar
{
if ( a == 0 || a == 1 )
int n ;
{

riy
cout << " ENTER THE NUMBER OF TERMS " ;
cout<< " NEITHER PRIME NOR COMPOSITE ";
cin >> n ;
}
cout<< "\n FIBONACCI SERIES\n " ;
else

si
fibo (n) ;
{
return 0;
for (j = 2 ; j<a; j++)
{ if (a%j==0)
.a }
w
{ cout<< "\tCOMPOSITE" ;
break ;
w

}
w

}
if ( a==j )
cout<< "\tPRIME" ;
}
}
void fibo ( int n )
{

www.tnschoolvideos.blogspot.in www.tnmanavan.blogspot.com

You might also like