SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
1   /*********************************************************
 2   /* Sample program for increment and decrement operators               *
 3   /* Illustrating the difference between prefix and postfix operations  *
 4   /* Also illustrates the use of escape squence t for creating columns *
 5   /* TSPaccarangan                                                      *
 6   /* September 13, 2009                                                 *
 7   /********************************************************/
 8   #include <iostream>
 9   using namespace std;
10
11   int main()
12   {
13          int num=9;
14          int store(0);
15          cout << "Let num be equal to 9: num = 9.n";
16          num++;
17          cout << "Using the expression num++ the value of that number is now: " << num << ".n";
18          num--;
19          cout << "nNow, using the expression num-- the value of the number is back to: “
20          cout << num << ".n";
21          cout << "nLet's play some more :)n";
22          cout << "nLet us now assign the output of num++ and ++num in another variable store.n";
23          store = 10*num++;
24          cout << "nWith the statement store = 10 * num++, n" << " new num is " << num << endl;
25          cout << " and store is " << store << endl;
26          num--;
27          store = 10*++num;
28          cout << "nWith the statement store = 10 * ++num,n" << " new num is " << num << endl;
29          cout << " and store is " << store << endl;
30
31              cout << "nnLet's use a table to display the previous discussion. nn";
32
33              cout << "t|statementtt|old numt|num used in *t|storet|new numn";
34              cout << "t|store = 10*num++t|9tt|9tt|90t|10n";
35              cout << "t|store = 10*++numt|9tt|10tt|100t|10n";
36              cout << "nnum is increased by 1 in both instances.n";
37              cout << "But the values multiplied by the constant are different.n";
38
39              return 0;
40   }




     F o r u s e i n c o n j u n c t i o n w i t h l e s s o n o n I n c r e m e n t a n d D e c r e m e n t O p e r a t o r s Se p t e m b e r 1 4 , 2 0 0 9

Weitere ähnliche Inhalte

Was ist angesagt?

最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10
Masahiro Nagano
 
Q1 create a java desktop application to find the largest number among the t...
Q1  create a java desktop application to find the largest number  among the t...Q1  create a java desktop application to find the largest number  among the t...
Q1 create a java desktop application to find the largest number among the t...
Manoj Bhakuni
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
Dirkjan Bussink
 

Was ist angesagt? (20)

2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10最近作ったN個のCPANモジュール Yokohama.pm #10
最近作ったN個のCPANモジュール Yokohama.pm #10
 
Q1 create a java desktop application to find the largest number among the t...
Q1  create a java desktop application to find the largest number  among the t...Q1  create a java desktop application to find the largest number  among the t...
Q1 create a java desktop application to find the largest number among the t...
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
Live in shell
Live in shellLive in shell
Live in shell
 
windshield defrost
windshield defrostwindshield defrost
windshield defrost
 
Sujet bac info 2013 g1, g2 et g3 avec correction
Sujet bac info 2013 g1, g2 et g3 avec correctionSujet bac info 2013 g1, g2 et g3 avec correction
Sujet bac info 2013 g1, g2 et g3 avec correction
 
Circular queue
Circular queueCircular queue
Circular queue
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Exploring Color Spaces
 with Gesture Tracking and Smart Bulbs (Distill 2014)
Exploring Color Spaces
 with Gesture Tracking and Smart Bulbs (Distill 2014)Exploring Color Spaces
 with Gesture Tracking and Smart Bulbs (Distill 2014)
Exploring Color Spaces
 with Gesture Tracking and Smart Bulbs (Distill 2014)
 
Script
ScriptScript
Script
 
timingExercise
timingExercisetimingExercise
timingExercise
 
Libtcc and gwan
Libtcc and gwanLibtcc and gwan
Libtcc and gwan
 
Using zone.js
Using zone.jsUsing zone.js
Using zone.js
 
Assignment#1
Assignment#1Assignment#1
Assignment#1
 
C++
C++C++
C++
 
MFC Prog
MFC ProgMFC Prog
MFC Prog
 
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
Scalability comparison: Traditional fork-join-based parallelism vs. Goroutine...
 
Instalación de emu8086
Instalación de emu8086Instalación de emu8086
Instalación de emu8086
 

Ähnlich wie Inc decsourcefile

C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3
Ammara Javed
 
#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(
troutmanboris
 
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docx
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docxLab Assignment #6, part 3 Time ConversionProgram Name lab.docx
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docx
smile790243
 
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdfg++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
arakalamkah11
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
Warui Maina
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
alish sha
 

Ähnlich wie Inc decsourcefile (20)

Programación de C++, Función Case
Programación de C++, Función CaseProgramación de C++, Función Case
Programación de C++, Función Case
 
Oop1
Oop1Oop1
Oop1
 
C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3C++ Programming Club-Lecture 3
C++ Programming Club-Lecture 3
 
Project in programming
Project in programmingProject in programming
Project in programming
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 
Ch4
Ch4Ch4
Ch4
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212The Ring programming language version 1.10 book - Part 127 of 212
The Ring programming language version 1.10 book - Part 127 of 212
 
Pointer
PointerPointer
Pointer
 
#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(#include iostreamusing namespace std;double sumNums(
#include iostreamusing namespace std;double sumNums(
 
Bangun datar dan bangun ruang
Bangun datar dan bangun ruangBangun datar dan bangun ruang
Bangun datar dan bangun ruang
 
Checking Wine with PVS-Studio and Clang Static Analyzer
Checking Wine with PVS-Studio and Clang Static AnalyzerChecking Wine with PVS-Studio and Clang Static Analyzer
Checking Wine with PVS-Studio and Clang Static Analyzer
 
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docx
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docxLab Assignment #6, part 3 Time ConversionProgram Name lab.docx
Lab Assignment #6, part 3 Time ConversionProgram Name lab.docx
 
The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189The Ring programming language version 1.6 book - Part 25 of 189
The Ring programming language version 1.6 book - Part 25 of 189
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdfg++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 

Inc decsourcefile

  • 1. 1 /********************************************************* 2 /* Sample program for increment and decrement operators * 3 /* Illustrating the difference between prefix and postfix operations * 4 /* Also illustrates the use of escape squence t for creating columns * 5 /* TSPaccarangan * 6 /* September 13, 2009 * 7 /********************************************************/ 8 #include <iostream> 9 using namespace std; 10 11 int main() 12 { 13 int num=9; 14 int store(0); 15 cout << "Let num be equal to 9: num = 9.n"; 16 num++; 17 cout << "Using the expression num++ the value of that number is now: " << num << ".n"; 18 num--; 19 cout << "nNow, using the expression num-- the value of the number is back to: “ 20 cout << num << ".n"; 21 cout << "nLet's play some more :)n"; 22 cout << "nLet us now assign the output of num++ and ++num in another variable store.n"; 23 store = 10*num++; 24 cout << "nWith the statement store = 10 * num++, n" << " new num is " << num << endl; 25 cout << " and store is " << store << endl; 26 num--; 27 store = 10*++num; 28 cout << "nWith the statement store = 10 * ++num,n" << " new num is " << num << endl; 29 cout << " and store is " << store << endl; 30 31 cout << "nnLet's use a table to display the previous discussion. nn"; 32 33 cout << "t|statementtt|old numt|num used in *t|storet|new numn"; 34 cout << "t|store = 10*num++t|9tt|9tt|90t|10n"; 35 cout << "t|store = 10*++numt|9tt|10tt|100t|10n"; 36 cout << "nnum is increased by 1 in both instances.n"; 37 cout << "But the values multiplied by the constant are different.n"; 38 39 return 0; 40 } F o r u s e i n c o n j u n c t i o n w i t h l e s s o n o n I n c r e m e n t a n d D e c r e m e n t O p e r a t o r s Se p t e m b e r 1 4 , 2 0 0 9