SlideShare a Scribd company logo
NCBA&E
(National College of Business Administration & Economics)
Assignment On Prog. & Problem Solving-1
Submitted by
Hamna Ali
BSCS-2143246
Submitted to
Miss Atifa Athar
Oct. 9. 2014
Program 1: (Sum)
#include<iostream.h>
Int main()
{
int n1,n2 , sum;
cout<<"Enter first number=";
cin>>n1;
cout<<"Enter second number=";
cin>>n2;
sum=n1+n2;
cout<<"The sum is="<<sum;
return 0;
}
Output:
n1=5,n2=3
sum=n1+n2
(5+3=8)
Program 2: (Cube)
#include<iostream.h>
int main()
{
int num, cube;
cout<<"Enter Any Number=";
cin>>num;
cube=num*num*num;
cout<<"The Cube is="<<cube;
return 0;
}
Output:
Enter any number:15
cube of 15 is:3375
Program 3: (find the Area of a Rectangle)
#include<iostream.h>
int main()
{
int ˥,w, area;
cout<<"Enter length=";
cin>>˥;
cout<<"Enter width=";
cin>>w;
area=˥*w;
cout<<"The Area="<<area;
return 0;
}
Output:
Enter length=8
Enter width=6
Area=l*w
so,
Area is =48
Program 4: (Find Smaller of Two numbers using If Else statement)
#include<iostream.h>
main()
{
int n1,n2, smaller;
cout<<"Enter First no=";
cin>>n1;
cout<<"Enter Second no=";
cin>>n2;
if (n1<n2)
{
smaller=n1;
}
else
{
smaller=n2;
}
cout<<smaller;
return 0;
}
Output: (prog 4)
Enter first number
15
Enter second number
5
5 is smallest number
Program: 5 (Find multiplication of two numbers)
#include<iostream.h>
int main ()
{
int a,b,c;
cout<<"Enter the value of a=";
cin>>a;
cout<<"Enter the value of b=";
cin>>b;
c=a*b;
cout<<"The product of a & b is="<<c;
return 0;
}
Output:
Enter the value of a: 2 Enter the value of b:4 Product of a&b is=8
Program: 6 (Find Difference of two numbers using condition)
#include<iostream.h>
main ()
{
int n1,n2, difference;
cout<<"Enter First no=";
cin>>n1;
cout>>"Enter Second no=";
cin<<n2;
difference=n1-n2;
if (difference<0)
{
difference=difference*(-1);
}
cout <<difference;
return 0;
}
Output:
Enter first number:5
Enter second number:2
Difference of two numbers is 3
Program : 7 (Program that inputs a number and finds whether
it is even or odd using if-else statement).
#include<iostream.h>
main()
{
int n;
cout<<"Enter a number:";
cin>>n;
if (n%2==0)
cout<<n<<" is even.";
else
cout<<n<<" is odd.";
getch();
}
Output:
Enter a number:10
10 is even number.
Program :8 (Find division of two numbers)
#include<iostream.h>
int main()
{
cout<<"Enter first no=";
cin>>n1;
cout<<"Enter second no=";
cin>>n2;
divide=n1/n2;
cout<<"The division="<<divide;
return 0;
}
Output:
Enter first number;4
Enter second number:8
Division of two number is 2.

More Related Content

What's hot

Financial statement assignment
Financial statement assignmentFinancial statement assignment
Financial statement assignment
Muhammad Sher
 
working capital
working capitalworking capital
working capital
simmy2
 
GSK HRM (1)
GSK HRM (1)GSK HRM (1)
GSK HRM (1)
Arsalan Awan
 
Pushpak daikin
Pushpak daikinPushpak daikin
Pushpak daikin
Pushpak Mahalay
 
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdfFinal Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
Hira Naz
 
Financial analysis of unilever pakistan
Financial analysis of unilever pakistanFinancial analysis of unilever pakistan
Financial analysis of unilever pakistan
Muhammad Azam Aliani
 
Engro
EngroEngro
Engro
Ali Kamran
 
Slides for borrowing costs
Slides for borrowing costsSlides for borrowing costs
Slides for borrowing costs
Jathurika Mathyinparasan
 
Basix Model of micro finance
Basix Model  of micro financeBasix Model  of micro finance
Basix Model of micro finance
sikander kushwaha
 
Packges company
Packges companyPackges company
Packges company
Qamar Adeel
 
“Impact of packaging on consumer buying behavior"
“Impact of packaging on consumer buying behavior"“Impact of packaging on consumer buying behavior"
“Impact of packaging on consumer buying behavior"
Bhavik Parmar
 

What's hot (11)

Financial statement assignment
Financial statement assignmentFinancial statement assignment
Financial statement assignment
 
working capital
working capitalworking capital
working capital
 
GSK HRM (1)
GSK HRM (1)GSK HRM (1)
GSK HRM (1)
 
Pushpak daikin
Pushpak daikinPushpak daikin
Pushpak daikin
 
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdfFinal Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
Final Report STRATEGIC MANAGEMENT 12-Aug-2022.pdf
 
Financial analysis of unilever pakistan
Financial analysis of unilever pakistanFinancial analysis of unilever pakistan
Financial analysis of unilever pakistan
 
Engro
EngroEngro
Engro
 
Slides for borrowing costs
Slides for borrowing costsSlides for borrowing costs
Slides for borrowing costs
 
Basix Model of micro finance
Basix Model  of micro financeBasix Model  of micro finance
Basix Model of micro finance
 
Packges company
Packges companyPackges company
Packges company
 
“Impact of packaging on consumer buying behavior"
“Impact of packaging on consumer buying behavior"“Impact of packaging on consumer buying behavior"
“Impact of packaging on consumer buying behavior"
 

Similar to Programming-I assignment for BSCS students , NCBA&e

C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
Ankush Kumar
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
Yashpatel821746
 
7720
77207720
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
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Labsheet 5
Labsheet 5Labsheet 5
Labsheet 5
rohassanie
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
Ankit Dixit
 
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++ file
C++ fileC++ file
C++ file
Mukund Trivedi
 
C++ file
C++ fileC++ file
C++ file
Mukund Trivedi
 
Assignment c++12
Assignment c++12Assignment c++12
Assignment c++12
Syed Umair
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
Ûťţåm Ğűpţä
 
Cpp programs
Cpp programsCpp programs
Cpp programs
harman kaur
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
Arunav Ray
 
Lab-11-C-Problems.pptx
Lab-11-C-Problems.pptxLab-11-C-Problems.pptx
Lab-11-C-Problems.pptx
ShimoFcis
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdfc++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
ayush616992
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
C++ assignment
C++ assignmentC++ assignment
C++ assignment
Zohaib Ahmed
 

Similar to Programming-I assignment for BSCS students , NCBA&e (20)

C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
 
7720
77207720
7720
 
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
 
Qno 1 (d)
Qno 1 (d)Qno 1 (d)
Qno 1 (d)
 
Labsheet 5
Labsheet 5Labsheet 5
Labsheet 5
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
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++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
Assignment c++12
Assignment c++12Assignment c++12
Assignment c++12
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
 
Lab-11-C-Problems.pptx
Lab-11-C-Problems.pptxLab-11-C-Problems.pptx
Lab-11-C-Problems.pptx
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdfc++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
 
Qno 1 (e)
Qno 1 (e)Qno 1 (e)
Qno 1 (e)
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 

More from hamna ali

Comparison of Skype vs team viewer
Comparison of Skype vs team viewer Comparison of Skype vs team viewer
Comparison of Skype vs team viewer
hamna ali
 
Solving discipline and classroom management
Solving discipline and classroom management Solving discipline and classroom management
Solving discipline and classroom management
hamna ali
 
Philosophy, meaning and concept
Philosophy, meaning  and concept Philosophy, meaning  and concept
Philosophy, meaning and concept
hamna ali
 
Case study for research student
Case study  for research studentCase study  for research student
Case study for research student
hamna ali
 
Evaporator
EvaporatorEvaporator
Evaporator
hamna ali
 
Models of Curriculum planning
Models of Curriculum planningModels of Curriculum planning
Models of Curriculum planning
hamna ali
 
Case Study Research
Case Study Research Case Study Research
Case Study Research
hamna ali
 

More from hamna ali (7)

Comparison of Skype vs team viewer
Comparison of Skype vs team viewer Comparison of Skype vs team viewer
Comparison of Skype vs team viewer
 
Solving discipline and classroom management
Solving discipline and classroom management Solving discipline and classroom management
Solving discipline and classroom management
 
Philosophy, meaning and concept
Philosophy, meaning  and concept Philosophy, meaning  and concept
Philosophy, meaning and concept
 
Case study for research student
Case study  for research studentCase study  for research student
Case study for research student
 
Evaporator
EvaporatorEvaporator
Evaporator
 
Models of Curriculum planning
Models of Curriculum planningModels of Curriculum planning
Models of Curriculum planning
 
Case Study Research
Case Study Research Case Study Research
Case Study Research
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 

Programming-I assignment for BSCS students , NCBA&e

  • 1. NCBA&E (National College of Business Administration & Economics) Assignment On Prog. & Problem Solving-1 Submitted by Hamna Ali
  • 2. BSCS-2143246 Submitted to Miss Atifa Athar Oct. 9. 2014 Program 1: (Sum) #include<iostream.h> Int main() { int n1,n2 , sum; cout<<"Enter first number="; cin>>n1; cout<<"Enter second number="; cin>>n2; sum=n1+n2; cout<<"The sum is="<<sum;
  • 3. return 0; } Output: n1=5,n2=3 sum=n1+n2 (5+3=8) Program 2: (Cube) #include<iostream.h> int main() { int num, cube;
  • 4. cout<<"Enter Any Number="; cin>>num; cube=num*num*num; cout<<"The Cube is="<<cube; return 0; } Output: Enter any number:15 cube of 15 is:3375
  • 5. Program 3: (find the Area of a Rectangle) #include<iostream.h> int main() { int ˥,w, area; cout<<"Enter length="; cin>>˥; cout<<"Enter width="; cin>>w; area=˥*w; cout<<"The Area="<<area; return 0; } Output: Enter length=8
  • 6. Enter width=6 Area=l*w so, Area is =48 Program 4: (Find Smaller of Two numbers using If Else statement) #include<iostream.h> main() { int n1,n2, smaller; cout<<"Enter First no="; cin>>n1; cout<<"Enter Second no="; cin>>n2; if (n1<n2) { smaller=n1; } else
  • 7. { smaller=n2; } cout<<smaller; return 0; } Output: (prog 4) Enter first number 15 Enter second number 5 5 is smallest number Program: 5 (Find multiplication of two numbers) #include<iostream.h> int main ()
  • 8. { int a,b,c; cout<<"Enter the value of a="; cin>>a; cout<<"Enter the value of b="; cin>>b; c=a*b; cout<<"The product of a & b is="<<c; return 0; } Output: Enter the value of a: 2 Enter the value of b:4 Product of a&b is=8 Program: 6 (Find Difference of two numbers using condition) #include<iostream.h> main () { int n1,n2, difference;
  • 9. cout<<"Enter First no="; cin>>n1; cout>>"Enter Second no="; cin<<n2; difference=n1-n2; if (difference<0) { difference=difference*(-1); } cout <<difference; return 0; } Output: Enter first number:5 Enter second number:2 Difference of two numbers is 3
  • 10. Program : 7 (Program that inputs a number and finds whether it is even or odd using if-else statement). #include<iostream.h> main() { int n; cout<<"Enter a number:"; cin>>n; if (n%2==0) cout<<n<<" is even."; else cout<<n<<" is odd."; getch(); } Output: Enter a number:10 10 is even number.
  • 11. Program :8 (Find division of two numbers) #include<iostream.h> int main() { cout<<"Enter first no="; cin>>n1; cout<<"Enter second no="; cin>>n2; divide=n1/n2; cout<<"The division="<<divide; return 0;
  • 12. } Output: Enter first number;4 Enter second number:8 Division of two number is 2.