SlideShare a Scribd company logo
1 of 12
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

Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
Presentation skills
Presentation skillsPresentation skills
Presentation skillsNanda Palit
 
Using Project Work
Using Project WorkUsing Project Work
Using Project WorkDIEGOFMACIAS
 
7 Cs Ppt With Excercises
7 Cs Ppt With Excercises7 Cs Ppt With Excercises
7 Cs Ppt With Excercisesmakhtar79
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptxRahikAhmed1
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++Fahim Adil
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentationfazli khaliq
 
Knapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comKnapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comHemant Gautam
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structurekalyanineve
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programAAKASH KUMAR
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 

What's hot (16)

Types of proposal
Types of proposalTypes of proposal
Types of proposal
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Presentation skills
Presentation skillsPresentation skills
Presentation skills
 
Using Project Work
Using Project WorkUsing Project Work
Using Project Work
 
7 Cs Ppt With Excercises
7 Cs Ppt With Excercises7 Cs Ppt With Excercises
7 Cs Ppt With Excercises
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
Presentation skills
Presentation skillsPresentation skills
Presentation skills
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Knapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comKnapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.com
 
Loop invarient
Loop invarientLoop invarient
Loop invarient
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Lecture 21 - Preprocessor and Header File
Lecture 21 - Preprocessor and Header FileLecture 21 - Preprocessor and Header File
Lecture 21 - Preprocessor and Header File
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 

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

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 studenthamna ali
 
Models of Curriculum planning
Models of Curriculum planningModels of Curriculum planning
Models of Curriculum planninghamna 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

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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.