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

Computer Lecture 1
Computer  Lecture 1Computer  Lecture 1
Computer Lecture 1
Moiz Barry
 

What's hot (20)

How to write a C.V.
How to write a C.V.How to write a C.V.
How to write a C.V.
 
Arjun sop
Arjun sopArjun sop
Arjun sop
 
Top 10 programming languages for mobile app development
Top 10 programming languages for mobile app developmentTop 10 programming languages for mobile app development
Top 10 programming languages for mobile app development
 
Unit 6 & 7, BASICS OF TECHINICAL ENGLISH CODE 6465
Unit 6 & 7, BASICS OF TECHINICAL ENGLISH CODE 6465Unit 6 & 7, BASICS OF TECHINICAL ENGLISH CODE 6465
Unit 6 & 7, BASICS OF TECHINICAL ENGLISH CODE 6465
 
Informative Reports in Technical Writing
Informative Reports in Technical WritingInformative Reports in Technical Writing
Informative Reports in Technical Writing
 
Report writing
Report writingReport writing
Report writing
 
resume builder.pptx
resume builder.pptxresume builder.pptx
resume builder.pptx
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Technical Report Writing (Format of Final year project's thesis)
Technical Report Writing (Format of Final year project's thesis)Technical Report Writing (Format of Final year project's thesis)
Technical Report Writing (Format of Final year project's thesis)
 
A classification of programing languages
A classification of programing languagesA classification of programing languages
A classification of programing languages
 
Parts of letter
Parts of letterParts of letter
Parts of letter
 
Study in the czech republic presentation
Study in the czech republic presentationStudy in the czech republic presentation
Study in the czech republic presentation
 
business correspondence
business correspondencebusiness correspondence
business correspondence
 
internship Presentation
internship Presentationinternship Presentation
internship Presentation
 
Introduction to systems programming
Introduction to systems programmingIntroduction to systems programming
Introduction to systems programming
 
motivational letter for student VISA
motivational letter for student VISAmotivational letter for student VISA
motivational letter for student VISA
 
Precis writing
Precis writingPrecis writing
Precis writing
 
Compilers
CompilersCompilers
Compilers
 
Computer Lecture 1
Computer  Lecture 1Computer  Lecture 1
Computer Lecture 1
 
Project Report Format for Final Year Engineering Students
Project Report Format for Final Year Engineering StudentsProject Report Format for Final Year Engineering Students
Project Report Format for Final Year Engineering Students
 

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

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
 

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 (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

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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...
 

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.