SlideShare a Scribd company logo
Name Roll # Class Department Submitted to
Bilal
Maqbool
10 BS-SE I CS & IT Sir.Aftab
Naseem.
C++ Programs of if-else Structure
#include <iostream.h> 1
#include <conio.h>
void main()
{
int Units,Price;
int line_rent=150;
float Total;
cout<<"Enter Units Consumed=";
cin>>Units;
if((Units>=0) && (Units<=100))
{
Price=Units*5;
}
else if(Units>100 && Units<=200)
{
Price=Units*10;
}
else if((Units>200 && Units<=500))
{
Price=Units*15;
}
else if(Units>500)
{
Price=(Units*20)+1000;
}
else
{
cout<<"Invalid Unit Entered";
}
Total=Price+line_rent;
cout<<"Total Bill for the "<< Units <<" Units Consumed is Rs."<<Total;
getch();
#include <iostream.h> 2
#include <conio.h>
void main()
{
int Sales,Bonus,Fine,Comm;
Bonus=1000;
Fine=100;
cout<<"Sales=";
cin>>Sales;
if((Sales<=10000) && (Sales>=0))
{
if(Sales<=2000)
{
Comm=(5/100*Sales)-Fine;
}
else
{
Comm=(Sales*5/100);
}
}
else if(Sales>10000 && Sales<=20000)
{
Comm=(Sales*10/100);
}
else if(Sales>20000)
{
Comm=(Sales*15/100);
Comm+=Bonus;
}
else
{ cout<<"Ivalid NO."; }
cout<<"Commission on "<<Sales<<" is="<<Comm;
getch();
}
#include <iostream.h> 3
#include <conio.h>
void main()
{
int n;
cout<<"Enter an integer value=";
cin>>n;
if(n%5==0 && n%2==0)
{
cout<<"Number is divisible by 5 & 2"<<endl;
}
else
{
cout<<"Number is not divisible by 5 & 2"<<endl;
}
getch();
}
#include <iostream.h> 4
#include <conio.h>
void main()
{
float a,b,c,max;
cout<<"Enter first value=";
cin>>a;
cout<<"Enter second value=";
cin>>b;
cout<<"Enter third value=";
cin>>c;
max=a;
if(max<b)max=b;
if(max<c)max=c;
cout<<"Maximum value is="<<max;
getch();
}
#include <iostream.h> 5
#include <conio.h>
void main()
{
int n;
clrscr();
cout<<"Enter integer value=";
cin>>n;
if(n%2==0)
{ cout<<"Even No."; }
else
{ cout<<"Odd No."; }
getch();
}
#include <iostream.h> 6
#include <conio.h>
void main()
{
int Year;
clrscr();
cout<<"Enter value for Year=";
cin>>Year;
if(Year%4==0)
{
cout<<"Leap Year";
}
else
{
cout<<"Not Leap Year";
}
getch();
}
#include <iostream.h> 7
#include <conio.h>
void main()
{
int avg;
cout<<"Enter Average Marks=";
cin>>avg;
if(avg>=90)
{ cout<<"A+"; }
else if(avg>=80)
{ cout<<"Your Grade is A"; }
else if(avg>=70)
{ cout<<"Your Grade is B"; }
else if(avg>=55)
{ cout<<"Your Grade is C"; }
else if(avg>=45)
{ cout<<"Your Grade is D"; }
else if(avg>=33)
{ cout<<"Your Grade is E"; }
else
{ cout<<"Sorry! Your are FAIL"; }
getch();
}
#include <iostream.h> 8
#include <conio.h>
void main()
{
int n;
clrscr();
cout<<"Enter integer value=";
cin>>n;
if(n%2==0)
{ cout<<"Any body LOVES you";
}
else
{ cout<<"Any body HATES you";
}
getch();
}
#include <iostream.h> 9
#include <conio.h>
void main()
{
int A,B;
cout<<"Enter your height Person A in feet=";
cin>>A;
cout<<"Enter your height Person B in feet=";
cin>>B;
if(A>B)
{ cout<<"Person A is taller than Person B"; }
else if(A<B)
{ cout<<"Person B is taller than Person A"; }
else
{ cout<<"Person A & Person B, are of equal height"; }
getch();
}
#include <iostream.h> 10
#include <conio.h>
void main()
{
int marks;
cout<<"Enter your Marks in %age =";
cin>>marks;
if(marks>=85 && marks<=100)
{ cout<<"You will get admission on Merit and Scholarship."; }
else if(marks<85 && marks>=60)
{ cout<<"You will get admission on Merit."; }
else if(marks>100)
{ cout<<"Sorry! You entered wrong %age."; }
else if(marks<60 && marks>=45)
{ cout<<"You will get admission on Self-Support."; }
else if(marks<45 && marks>0)
{ cout<<"Sorry! You are not eligible."; }
else
{ cout<<"Sorry! You entered wrong %age."; }
getch();
}
C++ Programs of switch Structure
C++ Programs of loop Structure
#include <iostream.h> 1
#include <conio.h>
void main()
{
int n;
cout<<"Enter No. of weekdays as
1=Mon,2=Tues,3=Wed,4=Thus,5=Fri,6=Sat,7=Sun";
cin>>n;
switch(n)
{
case 1:
{ cout<<"Monday";
break; }
case 2:
{ cout<<"Tuesday";
break; }
case 3:
{ cout<<"Wednesday";
break; }
case 4:
{ cout<<"Thusday";
break; }
case 5:
{ cout<<"Friday";
break; }
case 6:
{ cout<<"Saturday";
break; }
case 7:
{ cout<<"Sunday";
break; }
default:
{ cout<<"Invalid No. entered"; }
}
getch();
}
#include <iostream.h> 2
#include <conio.h>
void main()
{
char ch;
cout<<"Enter a single character=";
cin>>ch;
switch(ch)
{
case'a':
case'A':
case'e':
case'E':
case'i':
case'I':
case'o':
case'O':
case'u':
case'U':
{ cout<<"It is a vowel";
break;
}
default:
{ cout<<"It is constant"; }
}
getch();
}
#include <iostream.h> 3
#include <conio.h>
void main()
{
int marks;
cout<<"Enter your marks in %age as 1 for more than 60%,
2 for less than 60%";
cin>>marks;
switch(marks)
{
case 1:
{
cout<<"You are Eligible for admission.";
break;
}
default:
{
cout<<"You are not Eligible for admission.";
}
}
getch();
}
#include <iostream.h> 4
#include <conio.h>
void main()
{
int game;
cout<<"Enter a number(1-9) to see your Future";
cin>>game;
switch(game)
{ case 1:
{ cout<<"You wiil remain Happy";
break; }
case 2:
{ cout<<"You wiil remain Sad";
break; }
case 3:
{ cout<<"You wiil remain Enjoful";
break; }
case 4:
{ cout<<"You wiil remain Lazy";
break; }
case 5:
{ cout<<"You wiil remain Charming";
break; }
case 6:
{ cout<<"You wiil remain ILL";
break; }
case 7:
{ cout<<"You wiil remain Angry";
break; }
case 8:
{ cout<<"You wiil remain Alone";
break; }
default:
{ cout<<"You wiil remain Healthy"; }
}
getch();
}
#include <iostream.h> 5
#include <conio.h>
void main()
{
int stars;
cout<<"Enter 5 to print five,10 for 10 & 15 for 15 stars=";
cin>>stars;
switch(stars)
{
case 5:
{ cout<<"*****";
break; }
case 10:
{ cout<<"**********";
break; }
default:
{ cout<<"***************"; }
}
getch();
}
#include <iostream.h> 1
#include <conio.h>
void main()
{
int sum=0;
for(int a=1;a<=5;a++)
{
sum+=a;
}
cout<<"Sum="<<sum;
getch();
}
#include <iostream.h> 2
#include <conio.h>
void main()
{
int num;
num=1;
while(num<=15)
{
cout<<'n'<<" Hello World ";
num++;
}
getch();
}#include <iostream.h> 3
#include <conio.h>
void main()
{
int square,cube,n;
n=2;
cout<<"No.tSquaretCuben";
while(n<=7)
{
cout<<n<<'t'<<n*n<<'t'<<n*n*n<<'t'<<endl;
n++;
}
getch();
}
#include <iostream.h> 4
#include <conio.h>
void main()
{ long n;
n=3;
while(n<=715)
{ cout<<n<<'t';
n*=5;
n++;
}
getch();
}
#include <iostream.h> 5
#include <conio.h>
void main()
{
long c,t,n;
cout<<"Enter a no. for table=";
cin>>n;
t=1;
while(t<=10)
{
c=n*t;
cout<<n<<"*"<<t<<"="<<c<<'n';
t++;
}
getch();
}
#include <iostream.h> 6
#include <conio.h>
void main()
{
long r,n;
cout<<"Enter any no.=";
cin>>n;
while(n>0)
{
r=n%10;
cout<<r;
n=n/10;
}
getch();
}
#include <iostream.h> 7
#include <conio.h>
void main()
{
float marks;
char st_name[25],st_address[15],opt;
do
{
cout<<"Enter name of student=";
cin>>st_name;
cout<<"Enter address of student=";
cin>>st_address;
cout<<"Enter obtained marks=";
cin>>marks;
cout<<"Student record is="<<endl;
cout<<st_name<<'t'<<st_address<<'t'<<marks<<endl;
cout<<"More Record [Y/N]?";
cin>>opt;
}
while(opt=='y'||opt=='Y');
{ cout<<"OK"; }
getch();
}
8
#include <iostream.h>
#include <conio.h>
void main()
{
int n,tab;
cin>>tab;
n=1;
do
{
cout<<n<<"X"<<tab<<"="<<tab*n<<endl;
n++;
}
while(n<=10);
getch();
}
#include <iostream.h> 9 #include <iostream.h> 10
C++ Programs of Nested loop Structure
#include <iostream.h> 1
#include <conio.h>
void main()
{
unsigned long n,p;
for(n=1,p=1;n<=10;n++)
{ if(n%2==1)
{
p=p*n;
cout<<n<<endl;
}
}
cout<<"Product of odd no's="<<p;
getch();
}
#include <iostream.h> 2
#include <conio.h>
void main()
{
int n;
for(n=2;n<=50;n++)
{
if(n%2==0)
{ cout<<n<<'t'; }
}
getch();
}
#include <iostream.h> 3
#include <conio.h>
void main()
{
int a=10;
char y;
do
{
for(int i=1;i<=10;i++)
{
cout<<a<<"*"<<i<<"="<<a*i<<endl;
}
cout<<"for repeat Y";
cin>>y;
}
while(y=='y' || y=='Y');
getch();
}
#include <iostream.h> 4
#include <conio.h>
void main()
{
int a=10;
char y;
do
{
for(int i=1;i<=10;i++)
{
cout<<"*"<<endl;;
}
cout<<"for repeat Y ";
cin>>y;
}
while(y=='y' || y=='Y');
getch();
}
#include <iostream.h> 5
#include <conio.h>
void main()
{
int a=11;
char y;
do
{
for(int i=1;i<=11;i++)
{
cout<<"This is nested loop"<<endl;;
}
cout<<"for repeat Y ";
cin>>y;
}
while(y=='y' || y=='Y');
getch();
}
#include <iostream.h> 6
#include <conio.h>
void main()
{ int a=2;
char y;
do
{ do
{ for(int i=1;i<=10;i++)
{ cout<<a<<"X"<<i<<"="<<a*i<<endl;;
}
cout<<"for repeat Y ";
cin>>y;
}
while(y=='y' || y=='Y');
cout<<"for again repeat y ";
cin>>y;
}
while(y=='Y' || y=='Y');
getch();
}

More Related Content

What's hot (8)

PDF
QA for PHP projects
Michelangelo van Dam
 
PDF
The Ring programming language version 1.5.2 book - Part 41 of 181
Mahmoud Samir Fayed
 
PDF
[KOSSA] C++ Programming - 17th Study - STL #3
Seok-joon Yun
 
KEY
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
PDF
Leveraging Symfony2 Forms
Bernhard Schussek
 
PPTX
A Test of Strength
Chris Oldwood
 
PDF
Martialask Нидерландия Шахбокс исторически събития и дати
FIDE Master Tihomir Dovramadjiev PhD
 
PPTX
ZIO: Powerful and Principled Functional Programming in Scala
Wiem Zine Elabidine
 
QA for PHP projects
Michelangelo van Dam
 
The Ring programming language version 1.5.2 book - Part 41 of 181
Mahmoud Samir Fayed
 
[KOSSA] C++ Programming - 17th Study - STL #3
Seok-joon Yun
 
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Leveraging Symfony2 Forms
Bernhard Schussek
 
A Test of Strength
Chris Oldwood
 
Martialask Нидерландия Шахбокс исторически събития и дати
FIDE Master Tihomir Dovramadjiev PhD
 
ZIO: Powerful and Principled Functional Programming in Scala
Wiem Zine Elabidine
 

Viewers also liked (6)

PDF
Arias carlos aporte individual_abastecimiento_agua
cariasumanizales
 
PDF
PWLSD.1 A critique of the cap theorem - Martin Kleppmann
Daniel Norman
 
PPTX
Chinatown ppt
Jessica Dailey
 
DOCX
MIDHUN ABRAHAM 02 resume
Midhun Abraham
 
PPTX
Ricardo oviedo impactos_incendios_forestales
Ricardo Andres Oviedo Celis
 
PPTX
Mktg 341 Commercial Crew Advertising Campaign
Claire Thrower
 
Arias carlos aporte individual_abastecimiento_agua
cariasumanizales
 
PWLSD.1 A critique of the cap theorem - Martin Kleppmann
Daniel Norman
 
Chinatown ppt
Jessica Dailey
 
MIDHUN ABRAHAM 02 resume
Midhun Abraham
 
Ricardo oviedo impactos_incendios_forestales
Ricardo Andres Oviedo Celis
 
Mktg 341 Commercial Crew Advertising Campaign
Claire Thrower
 
Ad

Similar to Programming assignment 02 (bilal maqbool 10) 2011 (20)

DOCX
Statement
Ahmad Kamal
 
PPTX
Cs1123 5 selection_if
TAlha MAlik
 
PDF
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
PPTX
Example Programs of CPP programs ch 1.pptx
DrVikasMahor
 
PPTX
Computational Physics Cpp Portiiion.pptx
khanzasad009
 
PPTX
Switch.pptx
AliAbro7
 
PPTX
Project in programming
sahashi11342091
 
PPTX
POLITEKNIK MALAYSIA
Aiman Hud
 
PPSX
Ramirez slideshow
janine_ramirez16
 
PDF
C++ Topic 1.pdf from Yangon Technological University
ShweEainLinn2
 
PPTX
Computational PhysicsssComputational Physics.pptx
khanzasad009
 
PPTX
Computer programming
Xhyna Delfin
 
PDF
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
 
PPT
Lecture04
elearning_portal
 
PDF
POP Unit 2.pptx.pdf for your time and gauss with example
siddarameshav871
 
DOC
Labsheet 4
rohassanie
 
PPTX
C++ loop
Khelan Ameen
 
DOCX
C++ assignment
Zohaib Ahmed
 
PPTX
Introduction to Selection control structures in C++
Neeru Mittal
 
PPT
Lecture#4 Algorithm and computing
NUST Stuff
 
Statement
Ahmad Kamal
 
Cs1123 5 selection_if
TAlha MAlik
 
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
Example Programs of CPP programs ch 1.pptx
DrVikasMahor
 
Computational Physics Cpp Portiiion.pptx
khanzasad009
 
Switch.pptx
AliAbro7
 
Project in programming
sahashi11342091
 
POLITEKNIK MALAYSIA
Aiman Hud
 
Ramirez slideshow
janine_ramirez16
 
C++ Topic 1.pdf from Yangon Technological University
ShweEainLinn2
 
Computational PhysicsssComputational Physics.pptx
khanzasad009
 
Computer programming
Xhyna Delfin
 
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
 
Lecture04
elearning_portal
 
POP Unit 2.pptx.pdf for your time and gauss with example
siddarameshav871
 
Labsheet 4
rohassanie
 
C++ loop
Khelan Ameen
 
C++ assignment
Zohaib Ahmed
 
Introduction to Selection control structures in C++
Neeru Mittal
 
Lecture#4 Algorithm and computing
NUST Stuff
 
Ad

More from Bilal Maqbool ツ (20)

PDF
Dld lecture module 01
Bilal Maqbool ツ
 
PDF
Complement
Bilal Maqbool ツ
 
PDF
Chapter10
Bilal Maqbool ツ
 
PDF
Uncdtalk
Bilal Maqbool ツ
 
PPTX
Okkkkk
Bilal Maqbool ツ
 
PDF
Dld lecture module 06
Bilal Maqbool ツ
 
PDF
Dld lecture module 05
Bilal Maqbool ツ
 
PDF
Dld lecture module 04 01
Bilal Maqbool ツ
 
PDF
Dld lecture module 03
Bilal Maqbool ツ
 
PDF
Dld lecture module 02
Bilal Maqbool ツ
 
PPTX
Lecture 3 report writtng
Bilal Maqbool ツ
 
PPTX
Lecture 2
Bilal Maqbool ツ
 
PPTX
Lecture 1 report writing
Bilal Maqbool ツ
 
DOCX
Bill gates
Bilal Maqbool ツ
 
DOCX
Programming assignment 30 12-11
Bilal Maqbool ツ
 
PPTX
Internet presentation
Bilal Maqbool ツ
 
DOCX
Presentation internet programming report
Bilal Maqbool ツ
 
DOCX
Magnetic storage devices
Bilal Maqbool ツ
 
DOCX
How internet technology be used to spread scientific awareness among pakistan...
Bilal Maqbool ツ
 
Dld lecture module 01
Bilal Maqbool ツ
 
Complement
Bilal Maqbool ツ
 
Dld lecture module 06
Bilal Maqbool ツ
 
Dld lecture module 05
Bilal Maqbool ツ
 
Dld lecture module 04 01
Bilal Maqbool ツ
 
Dld lecture module 03
Bilal Maqbool ツ
 
Dld lecture module 02
Bilal Maqbool ツ
 
Lecture 3 report writtng
Bilal Maqbool ツ
 
Lecture 1 report writing
Bilal Maqbool ツ
 
Bill gates
Bilal Maqbool ツ
 
Programming assignment 30 12-11
Bilal Maqbool ツ
 
Internet presentation
Bilal Maqbool ツ
 
Presentation internet programming report
Bilal Maqbool ツ
 
Magnetic storage devices
Bilal Maqbool ツ
 
How internet technology be used to spread scientific awareness among pakistan...
Bilal Maqbool ツ
 

Recently uploaded (20)

PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 

Programming assignment 02 (bilal maqbool 10) 2011

  • 1. Name Roll # Class Department Submitted to Bilal Maqbool 10 BS-SE I CS & IT Sir.Aftab Naseem.
  • 2. C++ Programs of if-else Structure #include <iostream.h> 1 #include <conio.h> void main() { int Units,Price; int line_rent=150; float Total; cout<<"Enter Units Consumed="; cin>>Units; if((Units>=0) && (Units<=100)) { Price=Units*5; } else if(Units>100 && Units<=200) { Price=Units*10; } else if((Units>200 && Units<=500)) { Price=Units*15; } else if(Units>500) { Price=(Units*20)+1000; } else { cout<<"Invalid Unit Entered"; } Total=Price+line_rent; cout<<"Total Bill for the "<< Units <<" Units Consumed is Rs."<<Total; getch(); #include <iostream.h> 2 #include <conio.h> void main() { int Sales,Bonus,Fine,Comm; Bonus=1000; Fine=100; cout<<"Sales="; cin>>Sales; if((Sales<=10000) && (Sales>=0)) { if(Sales<=2000) { Comm=(5/100*Sales)-Fine; } else { Comm=(Sales*5/100); } } else if(Sales>10000 && Sales<=20000) { Comm=(Sales*10/100); } else if(Sales>20000) { Comm=(Sales*15/100); Comm+=Bonus; } else { cout<<"Ivalid NO."; } cout<<"Commission on "<<Sales<<" is="<<Comm; getch(); } #include <iostream.h> 3 #include <conio.h> void main() { int n; cout<<"Enter an integer value="; cin>>n; if(n%5==0 && n%2==0) { cout<<"Number is divisible by 5 & 2"<<endl; } else { cout<<"Number is not divisible by 5 & 2"<<endl; } getch(); } #include <iostream.h> 4 #include <conio.h> void main() { float a,b,c,max; cout<<"Enter first value="; cin>>a; cout<<"Enter second value="; cin>>b; cout<<"Enter third value="; cin>>c; max=a; if(max<b)max=b; if(max<c)max=c; cout<<"Maximum value is="<<max; getch(); } #include <iostream.h> 5 #include <conio.h> void main() { int n; clrscr(); cout<<"Enter integer value="; cin>>n; if(n%2==0) { cout<<"Even No."; } else { cout<<"Odd No."; } getch(); } #include <iostream.h> 6 #include <conio.h> void main() { int Year; clrscr(); cout<<"Enter value for Year="; cin>>Year; if(Year%4==0) { cout<<"Leap Year"; } else { cout<<"Not Leap Year"; } getch(); } #include <iostream.h> 7 #include <conio.h> void main() { int avg; cout<<"Enter Average Marks="; cin>>avg; if(avg>=90) { cout<<"A+"; } else if(avg>=80) { cout<<"Your Grade is A"; } else if(avg>=70) { cout<<"Your Grade is B"; } else if(avg>=55) { cout<<"Your Grade is C"; } else if(avg>=45) { cout<<"Your Grade is D"; } else if(avg>=33) { cout<<"Your Grade is E"; } else { cout<<"Sorry! Your are FAIL"; } getch(); } #include <iostream.h> 8 #include <conio.h> void main() { int n; clrscr(); cout<<"Enter integer value="; cin>>n; if(n%2==0) { cout<<"Any body LOVES you"; } else { cout<<"Any body HATES you"; } getch(); } #include <iostream.h> 9 #include <conio.h> void main() { int A,B; cout<<"Enter your height Person A in feet="; cin>>A; cout<<"Enter your height Person B in feet="; cin>>B; if(A>B) { cout<<"Person A is taller than Person B"; } else if(A<B) { cout<<"Person B is taller than Person A"; } else { cout<<"Person A & Person B, are of equal height"; } getch(); }
  • 3. #include <iostream.h> 10 #include <conio.h> void main() { int marks; cout<<"Enter your Marks in %age ="; cin>>marks; if(marks>=85 && marks<=100) { cout<<"You will get admission on Merit and Scholarship."; } else if(marks<85 && marks>=60) { cout<<"You will get admission on Merit."; } else if(marks>100) { cout<<"Sorry! You entered wrong %age."; } else if(marks<60 && marks>=45) { cout<<"You will get admission on Self-Support."; } else if(marks<45 && marks>0) { cout<<"Sorry! You are not eligible."; } else { cout<<"Sorry! You entered wrong %age."; } getch(); }
  • 4. C++ Programs of switch Structure C++ Programs of loop Structure #include <iostream.h> 1 #include <conio.h> void main() { int n; cout<<"Enter No. of weekdays as 1=Mon,2=Tues,3=Wed,4=Thus,5=Fri,6=Sat,7=Sun"; cin>>n; switch(n) { case 1: { cout<<"Monday"; break; } case 2: { cout<<"Tuesday"; break; } case 3: { cout<<"Wednesday"; break; } case 4: { cout<<"Thusday"; break; } case 5: { cout<<"Friday"; break; } case 6: { cout<<"Saturday"; break; } case 7: { cout<<"Sunday"; break; } default: { cout<<"Invalid No. entered"; } } getch(); } #include <iostream.h> 2 #include <conio.h> void main() { char ch; cout<<"Enter a single character="; cin>>ch; switch(ch) { case'a': case'A': case'e': case'E': case'i': case'I': case'o': case'O': case'u': case'U': { cout<<"It is a vowel"; break; } default: { cout<<"It is constant"; } } getch(); } #include <iostream.h> 3 #include <conio.h> void main() { int marks; cout<<"Enter your marks in %age as 1 for more than 60%, 2 for less than 60%"; cin>>marks; switch(marks) { case 1: { cout<<"You are Eligible for admission."; break; } default: { cout<<"You are not Eligible for admission."; } } getch(); } #include <iostream.h> 4 #include <conio.h> void main() { int game; cout<<"Enter a number(1-9) to see your Future"; cin>>game; switch(game) { case 1: { cout<<"You wiil remain Happy"; break; } case 2: { cout<<"You wiil remain Sad"; break; } case 3: { cout<<"You wiil remain Enjoful"; break; } case 4: { cout<<"You wiil remain Lazy"; break; } case 5: { cout<<"You wiil remain Charming"; break; } case 6: { cout<<"You wiil remain ILL"; break; } case 7: { cout<<"You wiil remain Angry"; break; } case 8: { cout<<"You wiil remain Alone"; break; } default: { cout<<"You wiil remain Healthy"; } } getch(); } #include <iostream.h> 5 #include <conio.h> void main() { int stars; cout<<"Enter 5 to print five,10 for 10 & 15 for 15 stars="; cin>>stars; switch(stars) { case 5: { cout<<"*****"; break; } case 10: { cout<<"**********"; break; } default: { cout<<"***************"; } } getch(); }
  • 5. #include <iostream.h> 1 #include <conio.h> void main() { int sum=0; for(int a=1;a<=5;a++) { sum+=a; } cout<<"Sum="<<sum; getch(); } #include <iostream.h> 2 #include <conio.h> void main() { int num; num=1; while(num<=15) { cout<<'n'<<" Hello World "; num++; } getch(); }#include <iostream.h> 3 #include <conio.h> void main() { int square,cube,n; n=2; cout<<"No.tSquaretCuben"; while(n<=7) { cout<<n<<'t'<<n*n<<'t'<<n*n*n<<'t'<<endl; n++; } getch(); } #include <iostream.h> 4 #include <conio.h> void main() { long n; n=3; while(n<=715) { cout<<n<<'t'; n*=5; n++; } getch(); } #include <iostream.h> 5 #include <conio.h> void main() { long c,t,n; cout<<"Enter a no. for table="; cin>>n; t=1; while(t<=10) { c=n*t; cout<<n<<"*"<<t<<"="<<c<<'n'; t++; } getch(); } #include <iostream.h> 6 #include <conio.h> void main() { long r,n; cout<<"Enter any no.="; cin>>n; while(n>0) { r=n%10; cout<<r; n=n/10; } getch(); } #include <iostream.h> 7 #include <conio.h> void main() { float marks; char st_name[25],st_address[15],opt; do { cout<<"Enter name of student="; cin>>st_name; cout<<"Enter address of student="; cin>>st_address; cout<<"Enter obtained marks="; cin>>marks; cout<<"Student record is="<<endl; cout<<st_name<<'t'<<st_address<<'t'<<marks<<endl; cout<<"More Record [Y/N]?"; cin>>opt; } while(opt=='y'||opt=='Y'); { cout<<"OK"; } getch(); } 8 #include <iostream.h> #include <conio.h> void main() { int n,tab; cin>>tab; n=1; do { cout<<n<<"X"<<tab<<"="<<tab*n<<endl; n++; } while(n<=10); getch(); } #include <iostream.h> 9 #include <iostream.h> 10
  • 6. C++ Programs of Nested loop Structure #include <iostream.h> 1 #include <conio.h> void main() { unsigned long n,p; for(n=1,p=1;n<=10;n++) { if(n%2==1) { p=p*n; cout<<n<<endl; } } cout<<"Product of odd no's="<<p; getch(); } #include <iostream.h> 2 #include <conio.h> void main() { int n; for(n=2;n<=50;n++) { if(n%2==0) { cout<<n<<'t'; } } getch(); } #include <iostream.h> 3 #include <conio.h> void main() { int a=10; char y; do { for(int i=1;i<=10;i++) { cout<<a<<"*"<<i<<"="<<a*i<<endl; } cout<<"for repeat Y"; cin>>y; } while(y=='y' || y=='Y'); getch(); } #include <iostream.h> 4 #include <conio.h> void main() { int a=10; char y; do { for(int i=1;i<=10;i++) { cout<<"*"<<endl;; } cout<<"for repeat Y "; cin>>y; } while(y=='y' || y=='Y'); getch(); } #include <iostream.h> 5 #include <conio.h> void main() { int a=11; char y; do { for(int i=1;i<=11;i++) { cout<<"This is nested loop"<<endl;; } cout<<"for repeat Y "; cin>>y; } while(y=='y' || y=='Y'); getch(); } #include <iostream.h> 6 #include <conio.h> void main() { int a=2; char y; do { do { for(int i=1;i<=10;i++) { cout<<a<<"X"<<i<<"="<<a*i<<endl;; } cout<<"for repeat Y "; cin>>y; } while(y=='y' || y=='Y'); cout<<"for again repeat y "; cin>>y; } while(y=='Y' || y=='Y'); getch(); }