SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Downloaden Sie, um offline zu lesen
SJEM2231 STRUCTURED PROGRAMMING 
NAME : WAN MOHAMAD FARHAN BIN AB RAHMAN 
TUTORIAL 1/ LAB 1 (22nd SEPTEMBER 2014) 
QUESTION 1 
Write a program to print the word “Welcome”. 
#include <iostream> 
using namespace std; 
int main() 
{ 
cout << "Welcome n"; 
return 0; 
} 
//Output : 
Welcome 
QUESTION 2 
Write a program to print a sentence in a single line and in three lines as like below. 
Hello, welcome to C++ Programming and 
Hello, 
welcome to 
C++ Programming
#include <iostream> 
using namespace std; 
int main() 
{ 
cout << "Hello, welcome to C++ Programming n" ; 
return 0; 
} 
//Output : 
Hello, welcome to C++ Programming 
#include <iostream> 
using namespace std; 
int main() 
{ 
cout << "Hello,n welcome ton C++ Programmingn"; 
return 0; 
} 
//Output : 
Hello, 
welcome to 
C++ programming
QUESTION 3 
Write a program that prints the sum, difference and product of two integers. Initialize the integers with the values 14 and 8. 
#include <iostream> 
using namespace std; 
int main() 
{ 
int a,b ; 
int sum, difference, product; 
a=14; 
b=8; 
sum= a+b; 
difference= a-b; 
product= a*b; 
cout << sum <<"n"; 
cout << difference <<"n"; 
cout << product <<"n”; 
return 0; 
} 
// Output: 
22 
6 
112
QUESTION 4 
Write a program that prints the sum, difference, product, quotient, and remainder of two numbers that are input interactively. 
#include <iostream> 
using namespace std; 
int main() 
{ 
int a,b; 
int sum, diff, product, quotient, remainder; 
cout << "Please enter a value of a: " ; 
cin >> a; 
cout << "Please enter a value of b: " ; 
cin >> b; 
sum=a+b; 
diff=a-b; 
product=a*b; 
quotient=a / b; 
remainder = a%b; 
cout << “The sum of a and b is : “ << sum <<"n"; 
cout << “The difference of a and b is : “ << diff <<"n"; 
cout << “The product of a and b is : “ << product <<"n"; 
cout << “The quotient of a and b is : “ << quotient<<"n"; 
cout << “The remainder of a and b is : “<< remainder<<"n";
return 0; 
} 
//Output : 
Please enter a value of a: 34 
Please enter a value of b: 27 
The sum of a and b is : 61 
The difference of a and b is : 7 
The product of a and b is : 918 
The quotient of a and b is : 1 
The remainder of a and b is : 7 
QUESTION 5 
Write a program to read the floating point number and convert it to integer 
//Using truncate method 
#include <iostream> 
using namespace std; 
int main() 
{ 
float x; 
int y; 
cout<<"Please enter a decimal number : "; 
cin >> x; 
y=x; 
cout<<"The integer number you will get is : "<< y << endl; 
return 0; 
}
//Output_truncate : 
Please enter a decimal number : 45.77 
The integer number you will get is : 45 
//Using round off method directly : 
#include <iostream> 
#include <cmath> 
using namespace std; 
double round(double value) 
{ 
return(floor(value+0.5)); 
} 
int main() 
{ 
double x,value; 
int y; 
write: 
cout <<"Please enter a decimal number : "; 
cin >>x; 
y = round(x); 
cout<<"The integer number that you will get after round off is : "<< y<<endl; 
cout<<"Do you want to continue with other decimal number? n"; 
cout<<"Press 1 for Yes ornPress 2 for Nonn"; 
cin>> value; 
if(value==1)
{ 
goto write; 
} 
else if(value==2) 
{ 
return 0; 
} 
else 
{ 
cout<<"Error! Please understand the COMMAND!!" <<endl; 
goto write; 
} 
} 
//Output_roundoff to integer directly 
Please enter a decimal number : 56.44 
The integer number that you will get after round off is : 56 
Do you want to continue with other decimal number? 
Press 1 for Yes or 
Press 2 for No 
1 
Please enter a decimal number : 1000.87 
The integer number that you will get after round off is : 1001 
Do you want to continue with other decimal number?
Press 1 for Yes or 
Press 2 for No 
8 
Error! Please understand the COMMAND!! 
Please enter a decimal number : 194.499 
The integer number that you will get after round off is : 194 
Do you want to continue with other decimal number? 
Press 1 for Yes or 
Press 2 for No 
2 
Press any key to continue 
//Round off method by using setprecision() to set the decimal places : 
#include <iostream> 
#include <cmath> //nothing happened if we eliminate this cmath 
#include <iomanip> // Input output manipulator, use setprecision() 
using namespace std; 
int main() 
{ 
long double x,value; 
int y;
write: 
cout << "Please enter a decimal number : "; 
cin >>x; 
y = long double (x); 
cout<< "The integer number you will get is : "; 
cout<< fixed << setprecision (0) << x <<endl; 
/* fixed is used before setprecision() to ensure that when we set the setprecision(0), it will round off to integer, if we make setprecision(1), setprecision(2), etc ; it will round off to 1 decimal place ,2 decimal places and so on respectively */ 
cout<< "Do you want to continue with other decimal number?n"; 
cout<<"Press 1 for Yes ornPress 2 for Nonn"; 
cin>> value; 
if(value==1) 
{ 
goto write; // goto (statement); 
} 
else if(value==2) 
{ 
return 0; 
} 
else 
{ 
cout<< "Error! Please understand the COMMAND!!" <<endl; 
goto write; 
} 
}
//Output_round off method using setprecision() 
Please enter a decimal number : 454535.435 
The integer number you will get is : 454535 
Do you want to continue with other decimal number? 
Press 1 for Yes or 
Press 2 for No 
1 
Please enter a decimal number : 44.78 
The integer number you will get is : 45 
Do you want to continue with other decimal number? 
Press 1 for Yes or 
Press 2 for No 
1 
Please enter a decimal number : 0.999993 
The integer number you will get is : 1 
Do you want to continue with other decimal number? 
Press 1 for Yes or 
Press 2 for No 
2

Weitere ähnliche Inhalte

Was ist angesagt?

Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
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
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic typesmohamed sikander
 
Static and const members
Static and const membersStatic and const members
Static and const membersmohamed sikander
 
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))Alex Penso Romero
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingmohamed sikander
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th StudyChris Ohk
 

Was ist angesagt? (20)

C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
New presentation oop
New presentation oopNew presentation oop
New presentation oop
 
C++ file
C++ fileC++ file
C++ file
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
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
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Oop1
Oop1Oop1
Oop1
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))
Programa en C++ ( escriba 3 nĂşmeros y diga cual es el mayor))
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
C++ programs
C++ programsC++ programs
C++ programs
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Opp compile
Opp compileOpp compile
Opp compile
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 

Andere mochten auch

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++pratikbakane
 
Computer Math Day 03 Addition
Computer Math Day 03 AdditionComputer Math Day 03 Addition
Computer Math Day 03 AdditionA Jorge Garcia
 
Computer Based Math
Computer Based MathComputer Based Math
Computer Based Mathdwees
 
Computer math
Computer mathComputer math
Computer mathPDE1D
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]StructuresNora Youssef
 
Database Q&A
Database  Q&ADatabase  Q&A
Database Q&Aeduafo
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMAmira Dolce Farhana
 
Database Management System And Design Questions
Database Management System And Design QuestionsDatabase Management System And Design Questions
Database Management System And Design QuestionsSamir Sabry
 
2009 Punjab Technical University B.C.A Database Management System Question paper
2009 Punjab Technical University B.C.A Database Management System Question paper2009 Punjab Technical University B.C.A Database Management System Question paper
2009 Punjab Technical University B.C.A Database Management System Question paperMonica Sabharwal
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersAbdul Rahman Sherzad
 
Objective structured practical question
Objective structured practical questionObjective structured practical question
Objective structured practical questionAnisur Rahman
 
5 structured programming
5 structured programming 5 structured programming
5 structured programming hccit
 
Previous question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEBPrevious question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEBShabeeb Shabi
 
Computers as information and communication technology
Computers as information and communication technologyComputers as information and communication technology
Computers as information and communication technologyJunarie Ramirez
 
LA5_Generation of Programming Languages
LA5_Generation of Programming LanguagesLA5_Generation of Programming Languages
LA5_Generation of Programming LanguagesCma Mohd
 

Andere mochten auch (20)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Computer Math Day 03 Addition
Computer Math Day 03 AdditionComputer Math Day 03 Addition
Computer Math Day 03 Addition
 
Computer Based Math
Computer Based MathComputer Based Math
Computer Based Math
 
Computer math
Computer mathComputer math
Computer math
 
[SpLab3]Structures
[SpLab3]Structures[SpLab3]Structures
[SpLab3]Structures
 
Database Q&A
Database  Q&ADatabase  Q&A
Database Q&A
 
Fskik 1 nota
Fskik 1   notaFskik 1   nota
Fskik 1 nota
 
FINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEMFINAL PAPER FP304 DATABASE SYSTEM
FINAL PAPER FP304 DATABASE SYSTEM
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
Database Management System And Design Questions
Database Management System And Design QuestionsDatabase Management System And Design Questions
Database Management System And Design Questions
 
2009 Punjab Technical University B.C.A Database Management System Question paper
2009 Punjab Technical University B.C.A Database Management System Question paper2009 Punjab Technical University B.C.A Database Management System Question paper
2009 Punjab Technical University B.C.A Database Management System Question paper
 
Dbms Final Examination Answer Key
Dbms Final Examination Answer KeyDbms Final Examination Answer Key
Dbms Final Examination Answer Key
 
Mcs 16 solved assignment 2015-16
Mcs 16 solved assignment 2015-16Mcs 16 solved assignment 2015-16
Mcs 16 solved assignment 2015-16
 
Ada 95 - Structured programming
Ada 95 - Structured programmingAda 95 - Structured programming
Ada 95 - Structured programming
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
 
Objective structured practical question
Objective structured practical questionObjective structured practical question
Objective structured practical question
 
5 structured programming
5 structured programming 5 structured programming
5 structured programming
 
Previous question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEBPrevious question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEB
 
Computers as information and communication technology
Computers as information and communication technologyComputers as information and communication technology
Computers as information and communication technology
 
LA5_Generation of Programming Languages
LA5_Generation of Programming LanguagesLA5_Generation of Programming Languages
LA5_Generation of Programming Languages
 

Ă„hnlich wie C++ TUTORIAL 1

C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdfT17Rockstar
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)Sena Nama
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 
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
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Project in programming
Project in programmingProject in programming
Project in programmingsahashi11342091
 
Output in c++ (cout)
Output in c++ (cout)Output in c++ (cout)
Output in c++ (cout)Ghada Shebl
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++Marco Izzotti
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solvingSyed Umair
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control StructureMohammad Shaker
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
C++basics
C++basicsC++basics
C++basicsamna izzat
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxleovasquez17
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxleovasquez17
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.pptTatyaTope4
 

Ă„hnlich wie C++ TUTORIAL 1 (20)

C101-PracticeProblems.pdf
C101-PracticeProblems.pdfC101-PracticeProblems.pdf
C101-PracticeProblems.pdf
 
Practiceproblems(1)
Practiceproblems(1)Practiceproblems(1)
Practiceproblems(1)
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
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
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Project in programming
Project in programmingProject in programming
Project in programming
 
Output in c++ (cout)
Output in c++ (cout)Output in c++ (cout)
Output in c++ (cout)
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
Assignement of programming & problem solving
Assignement of programming & problem solvingAssignement of programming & problem solving
Assignement of programming & problem solving
 
Ch4
Ch4Ch4
Ch4
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control Structure
 
C++ loop
C++ loop C++ loop
C++ loop
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Statement
StatementStatement
Statement
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
C++basics
C++basicsC++basics
C++basics
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
 
c++basics.ppt
c++basics.pptc++basics.ppt
c++basics.ppt
 

KĂĽrzlich hochgeladen

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Dr. Mazin Mohamed alkathiri
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...Pooja Nehwal
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

KĂĽrzlich hochgeladen (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

C++ TUTORIAL 1

  • 1. SJEM2231 STRUCTURED PROGRAMMING NAME : WAN MOHAMAD FARHAN BIN AB RAHMAN TUTORIAL 1/ LAB 1 (22nd SEPTEMBER 2014) QUESTION 1 Write a program to print the word “Welcome”. #include <iostream> using namespace std; int main() { cout << "Welcome n"; return 0; } //Output : Welcome QUESTION 2 Write a program to print a sentence in a single line and in three lines as like below. Hello, welcome to C++ Programming and Hello, welcome to C++ Programming
  • 2. #include <iostream> using namespace std; int main() { cout << "Hello, welcome to C++ Programming n" ; return 0; } //Output : Hello, welcome to C++ Programming #include <iostream> using namespace std; int main() { cout << "Hello,n welcome ton C++ Programmingn"; return 0; } //Output : Hello, welcome to C++ programming
  • 3. QUESTION 3 Write a program that prints the sum, difference and product of two integers. Initialize the integers with the values 14 and 8. #include <iostream> using namespace std; int main() { int a,b ; int sum, difference, product; a=14; b=8; sum= a+b; difference= a-b; product= a*b; cout << sum <<"n"; cout << difference <<"n"; cout << product <<"n”; return 0; } // Output: 22 6 112
  • 4. QUESTION 4 Write a program that prints the sum, difference, product, quotient, and remainder of two numbers that are input interactively. #include <iostream> using namespace std; int main() { int a,b; int sum, diff, product, quotient, remainder; cout << "Please enter a value of a: " ; cin >> a; cout << "Please enter a value of b: " ; cin >> b; sum=a+b; diff=a-b; product=a*b; quotient=a / b; remainder = a%b; cout << “The sum of a and b is : “ << sum <<"n"; cout << “The difference of a and b is : “ << diff <<"n"; cout << “The product of a and b is : “ << product <<"n"; cout << “The quotient of a and b is : “ << quotient<<"n"; cout << “The remainder of a and b is : “<< remainder<<"n";
  • 5. return 0; } //Output : Please enter a value of a: 34 Please enter a value of b: 27 The sum of a and b is : 61 The difference of a and b is : 7 The product of a and b is : 918 The quotient of a and b is : 1 The remainder of a and b is : 7 QUESTION 5 Write a program to read the floating point number and convert it to integer //Using truncate method #include <iostream> using namespace std; int main() { float x; int y; cout<<"Please enter a decimal number : "; cin >> x; y=x; cout<<"The integer number you will get is : "<< y << endl; return 0; }
  • 6. //Output_truncate : Please enter a decimal number : 45.77 The integer number you will get is : 45 //Using round off method directly : #include <iostream> #include <cmath> using namespace std; double round(double value) { return(floor(value+0.5)); } int main() { double x,value; int y; write: cout <<"Please enter a decimal number : "; cin >>x; y = round(x); cout<<"The integer number that you will get after round off is : "<< y<<endl; cout<<"Do you want to continue with other decimal number? n"; cout<<"Press 1 for Yes ornPress 2 for Nonn"; cin>> value; if(value==1)
  • 7. { goto write; } else if(value==2) { return 0; } else { cout<<"Error! Please understand the COMMAND!!" <<endl; goto write; } } //Output_roundoff to integer directly Please enter a decimal number : 56.44 The integer number that you will get after round off is : 56 Do you want to continue with other decimal number? Press 1 for Yes or Press 2 for No 1 Please enter a decimal number : 1000.87 The integer number that you will get after round off is : 1001 Do you want to continue with other decimal number?
  • 8. Press 1 for Yes or Press 2 for No 8 Error! Please understand the COMMAND!! Please enter a decimal number : 194.499 The integer number that you will get after round off is : 194 Do you want to continue with other decimal number? Press 1 for Yes or Press 2 for No 2 Press any key to continue //Round off method by using setprecision() to set the decimal places : #include <iostream> #include <cmath> //nothing happened if we eliminate this cmath #include <iomanip> // Input output manipulator, use setprecision() using namespace std; int main() { long double x,value; int y;
  • 9. write: cout << "Please enter a decimal number : "; cin >>x; y = long double (x); cout<< "The integer number you will get is : "; cout<< fixed << setprecision (0) << x <<endl; /* fixed is used before setprecision() to ensure that when we set the setprecision(0), it will round off to integer, if we make setprecision(1), setprecision(2), etc ; it will round off to 1 decimal place ,2 decimal places and so on respectively */ cout<< "Do you want to continue with other decimal number?n"; cout<<"Press 1 for Yes ornPress 2 for Nonn"; cin>> value; if(value==1) { goto write; // goto (statement); } else if(value==2) { return 0; } else { cout<< "Error! Please understand the COMMAND!!" <<endl; goto write; } }
  • 10. //Output_round off method using setprecision() Please enter a decimal number : 454535.435 The integer number you will get is : 454535 Do you want to continue with other decimal number? Press 1 for Yes or Press 2 for No 1 Please enter a decimal number : 44.78 The integer number you will get is : 45 Do you want to continue with other decimal number? Press 1 for Yes or Press 2 for No 1 Please enter a decimal number : 0.999993 The integer number you will get is : 1 Do you want to continue with other decimal number? Press 1 for Yes or Press 2 for No 2