SlideShare a Scribd company logo
1 of 32
Download to read offline
Lab Manual
IV
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=2;
++a;
a++;
a++;
cout<<a;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=2; b=2;
++b;
b++;
a++;
a++;
cout<<a<<b;
getch();
}
Output of
a
Output of
a
b
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
--a;
a--;
--a;
a--;
cout<<a;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=4; b=4;
--b;
b--;
a--;
a--;
cout<<a<<b;
getch();
}
Output of
a
Output of
a
b
Unary with cout
Use of Unary Operators with cout
Output as
4
5
Output as
4
5
Output as
4
5
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
cout<<--a;
cout<<--a;
cout<<a--;
cout<<a;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=4; b=4;
cout<<b--;
cout<<b--;
cout<<b--;
cout<<b;
getch();
}
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
cout<<--a;
cout<<a--;
cout<<a--;
cout<<a--;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=4; b=4;
cout<<b--;
cout<<b;
cout<<b--;
cout<<++b;
cout<<b;
getch();
}
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
--a;
a++;
cout<<a--;
cout<<--a;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=4; b=4;
b--;
b++;
b--;
cout<<++b;
cout<<b--;
cout<<b
getch();
}
Unary Practice with
Assignment statement
Use of Unary Operators into = statement
Output as
c=4
d=5
Output as
c=4
d=5
Output as
c=4
d=5
b=6
Use of Unary Operators in = statement
Output as
D=8
E=11
A=12
Output as
D=8
E=11
A=12
B=7
Pre and Post Practice
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
a = b++;
a = a+2;
++a;
b = a++;
cout<<a<<b;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
b = ++b;
a = a++;
a--;
b = --a;
cout<<a<<b++;
getch();
}
Pre and Post into Expression
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
c = a + ++a + ++a;
cout<<a<<c;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
c = ++b + --b + b++;
cout<<b<<c;
getch();
}
Pre and Post Expression
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=b=8;
a = b + ++a + ++b;
cout<<a<<b;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c; a=b=c=4;
a = ++a + --a + b++;
cout<<a<<b;
getch();
}
Pre and Post Expression
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c; a=b=c=4;
a = ++a + --a + b++;
}
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c;
a=2; b=1;
a = ++b + a++;
b= b + ++a - ++b;
cout<<a<<b;
getch();
b = a-- + a-- + ++b + b;
cout<<a++<<b++;
cout<<a<<b;
getch();
Transform Expression into C++ Format
Mathematics Operator in C++ Example
+ + 2+4 =6
- - 4-2 = 2
X * 2*3 =6
/ 4/2 = 2
% (Percentage) % (Remaining) 10%2 = 0
32 3*3 or 3^3 or Power (3,2) 2^3 = 8
Sqrt (9) Sqrt (9) = 3
Transform Expression into C++ Format
Mathematics C++ Format
2+3+4 2+3+4
2-6-5 2-6-5
2X3 2*3
4/2
4%2 4%2
32 3*3
Sqrt (9)
Transform Expression into C++ Format
Mathematics Exp C++ Exp
2*3+4*10/2
3X6-33+7 3*6-(3*3*3)+7
32 Power (3,2)
3*5-Sqrt (9) + (3^2)
Transform Expression into C++ Program
Mathematics C++
2*3+4*10/2
#include<iostream.h>
#include<conio.h>
void main ( ) {
int a,b,c,d,e, ans;
a=2; b=3; c=4; d=10; e=2;
ans= a*b+c*d/e;
cout<<“answer=“<<ans;
getch(); }
Transform Expression into C++ Program
Mathematics C++
3X6-33+7 3*6-(3*3*3)+7
#include<iostream.h>
#include<conio.h>
void main ( ) {
int a,b,c,d,e, ans;
a=3; b=6; c=7;
exp= a*b-(a*a*a)+c;
cout<<“answer=“<<exp;
getch(); }
Transform Expression into C++ Program
Mathematics C++
3*5-Sqrt (9) + (3^2)
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main ( ) {
int a,b,c,d,e, ans;
a=3; b=5; c=9; d=3; e=2;
exp= a*b-sqrt(c)+ (d^2);
cout<<“answer=“<<exp;
getch(); }
Operator Precedence
Read expression from Left to Right
1. ( )
2 * , /, %
3 + , -
Solve Expression using Operator Precedence
Question Output
2 + 3 * 4 / 2+10 ?
( ( 2 + 3 ) * 4 / 2 + 10 ) ?
2 + 4 – 3 * 2 / 2 -10 % 2 + power(2,5) ?
( ( (5*(2+4) %2 )+10 )- sqrt (49) ) ?
(3 * 2 / 2 -10 % 2 + (5^2) ) ?
Solve Binary Operators in Expression
Output as
5 Output as
-3
Variable as a Constant
Output as
a=5
p=5
Output as
a=5
p=5
Constant Variable Value not Change
DEVC++
Output as
a=5
p=5
DEVC++
Output as
-15.6
Input Value at Run Time Screen
 If we want to input value at run time
cout<<a; cin>>a;
cout<<a<<b<<c; cin>>a>>b>>c;
Input at Runtime Screen
Using Turbo C++
a=5
Runtime screen
5 //input value & press
enter
a=5
Runtime screen
10 //input value &
press enter
a=10
Message before Input at Runtime Screen
More Input at Runtime Screen
More Input at Runtime Screen
Enter value at run time

More Related Content

Similar to Lab Manual IV (1).pdf on C++ Programming practice

Class xi sample paper (Computer Science)
Class xi sample paper (Computer Science)Class xi sample paper (Computer Science)
Class xi sample paper (Computer Science)
MountAbuRohini
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
ssuser3cbb4c
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
akaptur
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
rohassanie
 

Similar to Lab Manual IV (1).pdf on C++ Programming practice (20)

pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
CPP Quiz
CPP QuizCPP Quiz
CPP Quiz
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
Lab 1
Lab 1Lab 1
Lab 1
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 
Class xi sample paper (Computer Science)
Class xi sample paper (Computer Science)Class xi sample paper (Computer Science)
Class xi sample paper (Computer Science)
 
Deductive verification of unmodified Linux kernel library functions
Deductive verification of unmodified Linux kernel library functionsDeductive verification of unmodified Linux kernel library functions
Deductive verification of unmodified Linux kernel library functions
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
 
7720
77207720
7720
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C++
C++C++
C++
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 

Lab Manual IV (1).pdf on C++ Programming practice

  • 2. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=2; ++a; a++; a++; cout<<a; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=2; b=2; ++b; b++; a++; a++; cout<<a<<b; getch(); } Output of a Output of a b
  • 3. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; --a; a--; --a; a--; cout<<a; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=4; b=4; --b; b--; a--; a--; cout<<a<<b; getch(); } Output of a Output of a b
  • 5. Use of Unary Operators with cout Output as 4 5 Output as 4 5 Output as 4 5
  • 6. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; cout<<--a; cout<<--a; cout<<a--; cout<<a; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=4; b=4; cout<<b--; cout<<b--; cout<<b--; cout<<b; getch(); }
  • 7. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; cout<<--a; cout<<a--; cout<<a--; cout<<a--; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=4; b=4; cout<<b--; cout<<b; cout<<b--; cout<<++b; cout<<b; getch(); }
  • 8. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; --a; a++; cout<<a--; cout<<--a; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=4; b=4; b--; b++; b--; cout<<++b; cout<<b--; cout<<b getch(); }
  • 10. Use of Unary Operators into = statement Output as c=4 d=5 Output as c=4 d=5 Output as c=4 d=5 b=6
  • 11. Use of Unary Operators in = statement Output as D=8 E=11 A=12 Output as D=8 E=11 A=12 B=7
  • 12. Pre and Post Practice #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; a = b++; a = a+2; ++a; b = a++; cout<<a<<b; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; b = ++b; a = a++; a--; b = --a; cout<<a<<b++; getch(); }
  • 13. Pre and Post into Expression #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; c = a + ++a + ++a; cout<<a<<c; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; c = ++b + --b + b++; cout<<b<<c; getch(); }
  • 14. Pre and Post Expression #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=8; a = b + ++a + ++b; cout<<a<<b; getch(); } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=c=4; a = ++a + --a + b++; cout<<a<<b; getch(); }
  • 15. Pre and Post Expression } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=b=c=4; a = ++a + --a + b++; } #include<iostream.h> #include<conio.h> void main() { int a,b,c; a=2; b=1; a = ++b + a++; b= b + ++a - ++b; cout<<a<<b; getch(); b = a-- + a-- + ++b + b; cout<<a++<<b++; cout<<a<<b; getch();
  • 16. Transform Expression into C++ Format Mathematics Operator in C++ Example + + 2+4 =6 - - 4-2 = 2 X * 2*3 =6 / 4/2 = 2 % (Percentage) % (Remaining) 10%2 = 0 32 3*3 or 3^3 or Power (3,2) 2^3 = 8 Sqrt (9) Sqrt (9) = 3
  • 17. Transform Expression into C++ Format Mathematics C++ Format 2+3+4 2+3+4 2-6-5 2-6-5 2X3 2*3 4/2 4%2 4%2 32 3*3 Sqrt (9)
  • 18. Transform Expression into C++ Format Mathematics Exp C++ Exp 2*3+4*10/2 3X6-33+7 3*6-(3*3*3)+7 32 Power (3,2) 3*5-Sqrt (9) + (3^2)
  • 19. Transform Expression into C++ Program Mathematics C++ 2*3+4*10/2 #include<iostream.h> #include<conio.h> void main ( ) { int a,b,c,d,e, ans; a=2; b=3; c=4; d=10; e=2; ans= a*b+c*d/e; cout<<“answer=“<<ans; getch(); }
  • 20. Transform Expression into C++ Program Mathematics C++ 3X6-33+7 3*6-(3*3*3)+7 #include<iostream.h> #include<conio.h> void main ( ) { int a,b,c,d,e, ans; a=3; b=6; c=7; exp= a*b-(a*a*a)+c; cout<<“answer=“<<exp; getch(); }
  • 21. Transform Expression into C++ Program Mathematics C++ 3*5-Sqrt (9) + (3^2) #include<iostream.h> #include<conio.h> #include<math.h> void main ( ) { int a,b,c,d,e, ans; a=3; b=5; c=9; d=3; e=2; exp= a*b-sqrt(c)+ (d^2); cout<<“answer=“<<exp; getch(); }
  • 22. Operator Precedence Read expression from Left to Right 1. ( ) 2 * , /, % 3 + , -
  • 23. Solve Expression using Operator Precedence Question Output 2 + 3 * 4 / 2+10 ? ( ( 2 + 3 ) * 4 / 2 + 10 ) ? 2 + 4 – 3 * 2 / 2 -10 % 2 + power(2,5) ? ( ( (5*(2+4) %2 )+10 )- sqrt (49) ) ? (3 * 2 / 2 -10 % 2 + (5^2) ) ?
  • 24. Solve Binary Operators in Expression Output as 5 Output as -3
  • 25. Variable as a Constant Output as a=5 p=5 Output as a=5 p=5
  • 26. Constant Variable Value not Change DEVC++ Output as a=5 p=5 DEVC++ Output as -15.6
  • 27. Input Value at Run Time Screen  If we want to input value at run time cout<<a; cin>>a; cout<<a<<b<<c; cin>>a>>b>>c;
  • 28. Input at Runtime Screen Using Turbo C++ a=5 Runtime screen 5 //input value & press enter a=5 Runtime screen 10 //input value & press enter a=10
  • 29. Message before Input at Runtime Screen
  • 30. More Input at Runtime Screen
  • 31. More Input at Runtime Screen
  • 32. Enter value at run time