SlideShare a Scribd company logo
Assignment No.1
Submitted To: Adnan Nawaz
Submitted By: Syed Muhammad Umair Shah
Subject: Introduction to Programming
Department: Computer Science
Roll No. 12
Indus International Institute D.G.Khan
/*Write a program that generates the following output using a single nested loop
$
##
$$$
#### */
#include<iostream.h>
#include<conio.h>
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();
}
Output
/*Show 1st 8 FIBONACCI Number */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long int a=21,b=0,c=1,sum;
while(b<a)
{
cout<<c<<" ";
sum=b+c;
b=c;
c=sum;
}
getch();
}
Output
/*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();
}
Output
/*Show out
****
***
**
* */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j;
for(i=1;i<=4;i++)
{
for(j=i;j<=4;j++)
{
cout<<"*";
}
cout<<"n";
}
getch();
}
Output
/*Triangle */
#include<iostream.h>
#include<conio.h>
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();
}
Output
/*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";
}
getch();
}
Output
/*Take input of two n.o if 2nd n.o is greater than 1st,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();
}
Output
/*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();
}
Output
/* Show out
*
**
***
**** */
#include<iostream.h>
#include<conio.h>
void main()
{
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();
}
Output
/*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();
}
Output
/* d=++a + a-- - b++ + --c = 1*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=2,b=4,c=0,d;
d=++a + a-- - b++ + --c;
cout<<d;
getch();
}
Output
/*SUM OF 1ST 6TH PRIME NUMBER*/
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,sum=0,flag=1,x;
//outer Loop
for(i=1,x=0;x<=5;i++)
{
//inner Loop
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
flag=0;
break;
}
}
if(flag)
{
x++;
sum+=i;
cout<<i<<" + ";
}
else
{
flag=1;
}
}
cout<<"bb = "<<sum;
getch();
}
Output
/*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,age
9,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:" ;
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+a
ge7+age8+age9+age10;
AverageAge=TotalAge/10 ;
cout << " Average Age Of Class Is : " <<
AverageAge ;
getch();
}
Output
/*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;
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();
}
Output

More Related Content

What's hot

Operator overloading
Operator overloadingOperator overloading
Operator overloading
mohamed sikander
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
mohamed sikander
 
Static and const members
Static and const membersStatic and const members
Static and const members
mohamed sikander
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using csnsanth
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
Jaydip JK
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
mohamed sikander
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
Farhan Ab Rahman
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final Project
Haqnawaz Ch
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
1 (1)
1 (1)1 (1)
1 (1)
Krish Na
 

What's hot (16)

Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
C++ programs
C++ programsC++ programs
C++ programs
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using c
 
Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)Pattern printing-in-c(Jaydip Kikani)
Pattern printing-in-c(Jaydip Kikani)
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Student Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final ProjectStudent Data Base Using C/C++ Final Project
Student Data Base Using C/C++ Final Project
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
 
1 (1)
1 (1)1 (1)
1 (1)
 

Viewers also liked

Control statements
Control statementsControl statements
Control statements
raksharao
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loopsbsdeol28
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
Muhammad Tahir Bashir
 
Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming Language
Ahmad Idrees
 
C++ loop
C++ loop C++ loop
C++ loop
Khelan Ameen
 
Control statements
Control statementsControl statements
Control statements
Kanwalpreet Kaur
 

Viewers also liked (7)

Control statements
Control statementsControl statements
Control statements
 
C++ control loops
C++ control loopsC++ control loops
C++ control loops
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming Language
 
C++ loop
C++ loop C++ loop
C++ loop
 
Control statements
Control statementsControl statements
Control statements
 

Similar to Assignement of c++

Assignment c++12
Assignment c++12Assignment c++12
Assignment c++12
Syed Umair
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
RSathyaPriyaCSEKIOT
 
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
premrings
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third Year
Dezyneecole
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
AhalyaR
 
Programa.eje
Programa.ejePrograma.eje
Programa.ejeguapi387
 
Gaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third YearGaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third Year
dezyneecole
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
Syed Umair
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
Mitul Patel
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
Ûťţåm Ğűpţä
 
C questions
C questionsC questions
C questions
MD Rashid
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 

Similar to Assignement of c++ (20)

Assignment c++12
Assignment c++12Assignment c++12
Assignment c++12
 
pattern-printing-in-c.pdf
pattern-printing-in-c.pdfpattern-printing-in-c.pdf
pattern-printing-in-c.pdf
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
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
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third Year
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Tu1
Tu1Tu1
Tu1
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
Gaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third YearGaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third Year
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
C questions
C questionsC questions
C questions
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 

More from Syed Umair

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

More from 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
 
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
 
Static keyword u.s ass.(2)
Static keyword u.s ass.(2)Static keyword u.s ass.(2)
Static keyword u.s ass.(2)
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 

Assignement of c++

  • 1. Assignment No.1 Submitted To: Adnan Nawaz Submitted By: Syed Muhammad Umair Shah Subject: Introduction to Programming Department: Computer Science Roll No. 12 Indus International Institute D.G.Khan
  • 2. /*Write a program that generates the following output using a single nested loop $ ## $$$ #### */ #include<iostream.h> #include<conio.h> 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(); } Output
  • 3. /*Show 1st 8 FIBONACCI Number */ #include<iostream.h> #include<conio.h> void main() { clrscr(); long int a=21,b=0,c=1,sum; while(b<a) { cout<<c<<" "; sum=b+c; b=c; c=sum; } getch(); } Output
  • 4. /*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(); } Output
  • 5. /*Show out **** *** ** * */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j; for(i=1;i<=4;i++) { for(j=i;j<=4;j++) { cout<<"*"; } cout<<"n"; } getch(); } Output
  • 6. /*Triangle */ #include<iostream.h> #include<conio.h> 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(); } Output
  • 7. /*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"; } getch(); } Output
  • 8. /*Take input of two n.o if 2nd n.o is greater than 1st,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(); } Output
  • 9. /*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(); } Output
  • 10. /* Show out * ** *** **** */ #include<iostream.h> #include<conio.h> void main() { 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(); } Output
  • 11. /*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(); } Output
  • 12. /* d=++a + a-- - b++ + --c = 1*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int a=2,b=4,c=0,d; d=++a + a-- - b++ + --c; cout<<d; getch(); } Output
  • 13. /*SUM OF 1ST 6TH PRIME NUMBER*/ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i,j,sum=0,flag=1,x; //outer Loop for(i=1,x=0;x<=5;i++) { //inner Loop for(j=2;j<=i/2;j++) { if(i%j==0) { flag=0; break; } } if(flag) { x++; sum+=i; cout<<i<<" + "; } else { flag=1; } } cout<<"bb = "<<sum; getch(); } Output
  • 14. /*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,age 9,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:" ; 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+a ge7+age8+age9+age10; AverageAge=TotalAge/10 ; cout << " Average Age Of Class Is : " << AverageAge ; getch(); } Output
  • 15. /*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; 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(); } Output