Transcription of Introduction to Programming (in C++)
{{id}} {{{paragraph}}}
Introduction to Programming (in C++)IntroductionJordi Cortadella, RicardGavald , Fernando OrejasDept. of Computer Science, UPCO utline Programming examples Algorithms, Programming languages and computer programs Steps in the design of a program2 Dept. CS, UPCI ntroduction to ProgrammingFirst program in C++#include <iostream>using namespace std;// This program reads two numbers and// writes their sumintmain() {intx, y;cin>> x >> y;ints = x + y;cout<< s << endl;} Introduction to Programming Dept. CS, UPC3 Introduction to Programming Dept. CS, UPC4cincout>sum8 1321> sum-15 9-6>Calculate xy Algorithm: repeated multiplicationx x x xIntroduction to Programming Dept. CS, UPC5ytimesyxip=xi4301431343294332743481 Calculate xy#include <iostream>using namespace std;// Input: read two integer numbers,x and y,// such that y >= 0// Output: write xyintmain() {intx, y;cin>> x >> y;inti= 0;intp = 1;while(i<y) { // Repeat several times (y)i= i+ 1;p = p x; //p = xi}cout<< p << endl;} Introduction to Programming Dept.
A programming language •A programming language is a language used to describe instructions for a computer. •What’s in a programming language? –Data (numbers, strings, structures, …) –Instructions (arithmetic, sequence, repetition, …) •A programming language has very strict syntax and semantics, as it must be understood by a ...
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}