SlideShare uma empresa Scribd logo
1 de 15
Programming &ProblemSolving
1
/*Write a program that input two number interchange the value of and then display them
without using third variable.*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Entr 1st num : ";
cin>>a;
cout<<"Entr 2nd num : ";
cin>>b;
cout<<"Value Befor Swapping:"<<endl;
cout<<"1st num="<<a<<endl;
cout<<"2nd num="<<b<<endl;
a=a+b;
b=a-b;
a=a-b;
cout<<"Value After Swapping:"<<endl;
cout<<"1st num="<<a<<endl;
cout<<"2nd num="<<b<<endl;
getch();
}
Out Put
Programming &ProblemSolving
2
/*Take input of Three n.o if the are not Equal,then find the Smallest n.o*/
#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
int a,b,c;
cout<<"Entr 1st n.o = ";
cin>>a;
cout<<"Entr 2nd n.o = ";
cin>>b;
cout<<"Entr 3rd n.o = ";
cin>>c;
if((a<b)&&(a<c))
cout<<"Smallest n.o is = "<<a;
else if((c<a) && (c<b)){
cout<<"Smallest n.o is = "<<c;}
else if((b<a) && (b<c)){
cout<<"Smallest n.o is = "<<b;}
else{
cout<<"All n.o are Equal";}
Programming &ProblemSolving
3
getch();
}
Out Put
/*Take input of two n.o if 1st n.o is greater than 2nd,display the division
as follow i.e. 1st=16 2nd=5 Ans=5*3+1=16*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n1,n2;
cout<<"Entr 1st no. = ";
cin>>n1;
cout<<"Entr 2nd no. = " ;
cin>>n2;
if(n2>n1)
{
cout<<"invalide input";
}
else
cout<<n2<<" * "<<n1/n2<<" + "<<n1%n2<<" = "<<n1<<"n";
getch();
Programming &ProblemSolving
4
}
Out Put
/*Show out
*****
*****
***** */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=5;j++)
{
cout<<"*";
}
cout<<"n";
}
getch();
}
Programming &ProblemSolving
5
Out Put
/*Take input a n.o and find if it is divisible by 10 or not*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
cout<<"Entr any number = ";
cin>>a;
if(a%10==0)
{
cout<<"it is Divisible by 10";
}
else
{
cout<<"it is not Divisible by 10";
}
getch();
Programming &ProblemSolving
6
}
Out Put
/*entr 10 student age and show average age*/
#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
float age1,age2,age3,age4,age5,age6,age7,age8,age9,age10;
float TotalAge;
float AverageAge;
cout <<" Please Enter The Age Of Student 1:" ;
cin >> age1;
cout <<" Please Enter The Age Of Student 2:" ;
cin >> age2;
cout <<" Please Enter The Age Of Student 3:" ;
cin >> age3;
cout <<" Please Enter The Age Of Student 4:" ;
cin >> age4;
cout <<" Please Enter The Age Of Student 5:" ;
cin >> age5;
cout <<" Please Enter The Age Of Student 6:" ;
Programming &ProblemSolving
7
cin >> age6;
cout <<" Please Enter The Age Of Student 7:" ;
cin >> age7;
cout <<" Please Enter The Age Of Student 8:" ;
cin >> age8;
cout <<" Please Enter The Age Of Student 9:" ;
cin >> age9;
cout <<" Please Enter The Age Of Student 10:" ;
cin >> age10;
TotalAge=age1+age2+age3+age4+age5+age6+age7+age8+age9+age10;
AverageAge=TotalAge/10 ;
cout << " Average Age Of Class Is : " << AverageAge ;
getch();
}
Out Put
/*Show 1st 8 FIBONACCI Number */
#include<iostream.h>
#include<conio.h>
void main()
Programming &ProblemSolving
8
{
clrscr();
long int a=21,b=0,c=1,sum;
while(b<a)
{
cout<<c<<" ";
sum=b+c;
b=c;
c=sum;
}
getch();
}
Out Put
/* Show out
*
**
***
**** */
#include<iostream.h>
#include<conio.h>
void main()
Programming &ProblemSolving
9
{
clrscr();
int i,j,sp;
for(i=1;i<=4;i++){
for(sp=1;sp<=4-i;sp++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<"*";}
cout<<"n";
}
getch();
}
Out Put
/*Triangle */
#include<iostream.h>
#include<conio.h>
Programming &ProblemSolving
10
void main() //if(i==1&&i==4&&j==1&&j==x)
{
clrscr();
int i,j,sp,x=1;
for(i=1;i<=4;i++,x=x+2)
{
for(sp=1;sp<=4-i;sp++) cout<<" ";
for(j=1;j<=x;j++)
{
if(i>1&&i<4&&j>1&&j<x)
cout<<" ";
else
cout<<"*";
}
cout<<"n";
}
getch();
}
Out Put
Programming &ProblemSolving
11
/*SUM OF 1ST 6TH PRIME NUMBER*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,sum=0,flag=1,x;
for(i=1,x=0;x<=5;i++)
{
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
if(flag)
{
x++;
sum+=i;
cout<<i<<" + ";
}
Programming &ProblemSolving
12
else
{
flag=1;
}
}
cout<<"bb = "<<sum;
getch();}
Out Put
/*Enter The Amount Of The Bill And Discount At The Rate Of 10% */
#include <iostream.h>
#include<conio.h>
void main ()
{
clrscr();
double amount,discount,netpayable;
cout << " Please Enter The Amount Of The Bill ";
cin >> amount;
if(amount>5000)
{
discount = amount*(15.0/100);
netpayable = amount-discount;
cout <<" The Discount At The Rate Of 15 % is Rupees " << discount << endl;
Programming &ProblemSolving
13
cout << " The Payable Amount is Rupees " << netpayable;
}
else
{
discount = amount*(10.0/100);
netpayable = amount-discount;
cout <<" The Discount At The Rate Of 10 % is Rupees " << discount << endl;
cout << " The Payable Amount is Rupees " << netpayable;
}
getch();
}
Out Put
/*Show out
****
***
**
* */
#include<iostream.h>
#include<conio.h>
void main()
{
Programming &ProblemSolving
14
clrscr();
int i,j;
for(i=1;i<=4;i++)
{
for(j=i;j<=4;j++)
{
cout<<"*";
}
cout<<"n";
}
getch();
}
Out Put
/*Write a program that generates the following output using a single nested loop
$
##
$$$
#### */
#include<iostream.h>
#include<conio.h>
Programming &ProblemSolving
15
void main()
{
clrscr();
int i,j;
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
if(i%2==0)
cout<<"#";
else
cout<<"$";
cout<<"n";
}
getch();
}
Out Put

Mais conteúdo relacionado

Mais procurados (20)

งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
Assignment#1
Assignment#1Assignment#1
Assignment#1
 
C++ programs
C++ programsC++ programs
C++ programs
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
c plus plus programsSlide
c plus plus programsSlidec plus plus programsSlide
c plus plus programsSlide
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
Tugas Program C++
Tugas Program C++Tugas Program C++
Tugas Program C++
 
Function basics
Function basicsFunction basics
Function basics
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)Program Kasir c++(case ROti88)
Program Kasir c++(case ROti88)
 
MFC Rect2
MFC Rect2MFC Rect2
MFC Rect2
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
1
11
1
 
Oopsprc1e
Oopsprc1eOopsprc1e
Oopsprc1e
 
basic programs in C++
basic programs in C++ basic programs in C++
basic programs in C++
 

Semelhante a Assignement of programming & problem solving

54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
Laporan pd kelompok 6
Laporan pd kelompok 6Laporan pd kelompok 6
Laporan pd kelompok 6phoe3
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaonyash production
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)Sena Nama
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdfT17Rockstar
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsMuhammadTalha436
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.pptLokeshK66
 

Semelhante a Assignement of programming & problem solving (20)

Project in programming
Project in programmingProject in programming
Project in programming
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
C++ file
C++ fileC++ file
C++ file
 
Laporan pd kelompok 6
Laporan pd kelompok 6Laporan pd kelompok 6
Laporan pd kelompok 6
 
C++ practical
C++ practicalC++ practical
C++ practical
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
C++ file
C++ fileC++ file
C++ file
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
10 template code program
10 template code program10 template code program
10 template code program
 
I PUC CS Lab_programs
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programs
 
c++ practical Digvajiya collage Rajnandgaon
c++ practical  Digvajiya collage Rajnandgaonc++ practical  Digvajiya collage Rajnandgaon
c++ practical Digvajiya collage Rajnandgaon
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)
 
C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdf
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
 
ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
 
Statement
StatementStatement
Statement
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Ch7
Ch7Ch7
Ch7
 
Ch7
Ch7Ch7
Ch7
 

Mais de Syed Umair

Mais de Syed Umair (20)

Assignement code
Assignement codeAssignement code
Assignement code
 
Tree 4
Tree 4Tree 4
Tree 4
 
Title page
Title pageTitle page
Title page
 
S.k
S.kS.k
S.k
 
Q.a
Q.aQ.a
Q.a
 
Prog
ProgProg
Prog
 
Perception
PerceptionPerception
Perception
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
M.b
M.bM.b
M.b
 
C++ 4
C++ 4C++ 4
C++ 4
 
B.g
B.gB.g
B.g
 
Assignement of discrete mathematics
Assignement of discrete mathematicsAssignement of discrete mathematics
Assignement of discrete mathematics
 
A.i
A.iA.i
A.i
 
H m
H mH m
H m
 
Prog
ProgProg
Prog
 
Assignment c++12
Assignment c++12Assignment c++12
Assignment c++12
 
Assignement of discrete mathematics
Assignement of discrete mathematicsAssignement of discrete mathematics
Assignement of discrete mathematics
 
Assignement c++
Assignement c++Assignement c++
Assignement c++
 
Truth table a.r
Truth table a.rTruth table a.r
Truth table a.r
 

Último

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Assignement of programming & problem solving

  • 1. Programming &ProblemSolving 1 /*Write a program that input two number interchange the value of and then display them without using third variable.*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b; cout<<"Entr 1st num : "; cin>>a; cout<<"Entr 2nd num : "; cin>>b; cout<<"Value Befor Swapping:"<<endl; cout<<"1st num="<<a<<endl; cout<<"2nd num="<<b<<endl; a=a+b; b=a-b; a=a-b; cout<<"Value After Swapping:"<<endl; cout<<"1st num="<<a<<endl; cout<<"2nd num="<<b<<endl; getch(); } Out Put
  • 2. Programming &ProblemSolving 2 /*Take input of Three n.o if the are not Equal,then find the Smallest n.o*/ #include<iostream.h> #include<conio.h> void main(){ clrscr(); int a,b,c; cout<<"Entr 1st n.o = "; cin>>a; cout<<"Entr 2nd n.o = "; cin>>b; cout<<"Entr 3rd n.o = "; cin>>c; if((a<b)&&(a<c)) cout<<"Smallest n.o is = "<<a; else if((c<a) && (c<b)){ cout<<"Smallest n.o is = "<<c;} else if((b<a) && (b<c)){ cout<<"Smallest n.o is = "<<b;} else{ cout<<"All n.o are Equal";}
  • 3. Programming &ProblemSolving 3 getch(); } Out Put /*Take input of two n.o if 1st n.o is greater than 2nd,display the division as follow i.e. 1st=16 2nd=5 Ans=5*3+1=16*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int n1,n2; cout<<"Entr 1st no. = "; cin>>n1; cout<<"Entr 2nd no. = " ; cin>>n2; if(n2>n1) { cout<<"invalide input"; } else cout<<n2<<" * "<<n1/n2<<" + "<<n1%n2<<" = "<<n1<<"n"; getch();
  • 4. Programming &ProblemSolving 4 } Out Put /*Show out ***** ***** ***** */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j; for(i=1;i<=3;i++) { for(j=1;j<=5;j++) { cout<<"*"; } cout<<"n"; } getch(); }
  • 5. Programming &ProblemSolving 5 Out Put /*Take input a n.o and find if it is divisible by 10 or not*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int a; cout<<"Entr any number = "; cin>>a; if(a%10==0) { cout<<"it is Divisible by 10"; } else { cout<<"it is not Divisible by 10"; } getch();
  • 6. Programming &ProblemSolving 6 } Out Put /*entr 10 student age and show average age*/ #include <iostream.h> #include<conio.h> void main() { clrscr(); float age1,age2,age3,age4,age5,age6,age7,age8,age9,age10; float TotalAge; float AverageAge; cout <<" Please Enter The Age Of Student 1:" ; cin >> age1; cout <<" Please Enter The Age Of Student 2:" ; cin >> age2; cout <<" Please Enter The Age Of Student 3:" ; cin >> age3; cout <<" Please Enter The Age Of Student 4:" ; cin >> age4; cout <<" Please Enter The Age Of Student 5:" ; cin >> age5; cout <<" Please Enter The Age Of Student 6:" ;
  • 7. Programming &ProblemSolving 7 cin >> age6; cout <<" Please Enter The Age Of Student 7:" ; cin >> age7; cout <<" Please Enter The Age Of Student 8:" ; cin >> age8; cout <<" Please Enter The Age Of Student 9:" ; cin >> age9; cout <<" Please Enter The Age Of Student 10:" ; cin >> age10; TotalAge=age1+age2+age3+age4+age5+age6+age7+age8+age9+age10; AverageAge=TotalAge/10 ; cout << " Average Age Of Class Is : " << AverageAge ; getch(); } Out Put /*Show 1st 8 FIBONACCI Number */ #include<iostream.h> #include<conio.h> void main()
  • 8. Programming &ProblemSolving 8 { clrscr(); long int a=21,b=0,c=1,sum; while(b<a) { cout<<c<<" "; sum=b+c; b=c; c=sum; } getch(); } Out Put /* Show out * ** *** **** */ #include<iostream.h> #include<conio.h> void main()
  • 9. Programming &ProblemSolving 9 { clrscr(); int i,j,sp; for(i=1;i<=4;i++){ for(sp=1;sp<=4-i;sp++) { cout<<" "; } for(j=1;j<=i;j++) { cout<<"*";} cout<<"n"; } getch(); } Out Put /*Triangle */ #include<iostream.h> #include<conio.h>
  • 10. Programming &ProblemSolving 10 void main() //if(i==1&&i==4&&j==1&&j==x) { clrscr(); int i,j,sp,x=1; for(i=1;i<=4;i++,x=x+2) { for(sp=1;sp<=4-i;sp++) cout<<" "; for(j=1;j<=x;j++) { if(i>1&&i<4&&j>1&&j<x) cout<<" "; else cout<<"*"; } cout<<"n"; } getch(); } Out Put
  • 11. Programming &ProblemSolving 11 /*SUM OF 1ST 6TH PRIME NUMBER*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j,sum=0,flag=1,x; for(i=1,x=0;x<=5;i++) { for(j=2;j<=i/2;j++) { if(i%j==0) { flag=0; break; } } if(flag) { x++; sum+=i; cout<<i<<" + "; }
  • 12. Programming &ProblemSolving 12 else { flag=1; } } cout<<"bb = "<<sum; getch();} Out Put /*Enter The Amount Of The Bill And Discount At The Rate Of 10% */ #include <iostream.h> #include<conio.h> void main () { clrscr(); double amount,discount,netpayable; cout << " Please Enter The Amount Of The Bill "; cin >> amount; if(amount>5000) { discount = amount*(15.0/100); netpayable = amount-discount; cout <<" The Discount At The Rate Of 15 % is Rupees " << discount << endl;
  • 13. Programming &ProblemSolving 13 cout << " The Payable Amount is Rupees " << netpayable; } else { discount = amount*(10.0/100); netpayable = amount-discount; cout <<" The Discount At The Rate Of 10 % is Rupees " << discount << endl; cout << " The Payable Amount is Rupees " << netpayable; } getch(); } Out Put /*Show out **** *** ** * */ #include<iostream.h> #include<conio.h> void main() {
  • 14. Programming &ProblemSolving 14 clrscr(); int i,j; for(i=1;i<=4;i++) { for(j=i;j<=4;j++) { cout<<"*"; } cout<<"n"; } getch(); } Out Put /*Write a program that generates the following output using a single nested loop $ ## $$$ #### */ #include<iostream.h> #include<conio.h>
  • 15. Programming &ProblemSolving 15 void main() { clrscr(); int i,j; for(i=1;i<=4;i++) { for(j=1;j<=i;j++) if(i%2==0) cout<<"#"; else cout<<"$"; cout<<"n"; } getch(); } Out Put