Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

C++ Programming/Code/Variables/Examples

From Wikibooks, open books for an open world
<C++ Programming

Variables

Adds two numbers and prints their sum

// This program adds two numbers and prints their sum.#include<iostream>intmain(){inta;intb;intsum;sum=a+b;std::cout<<"The sum of "<<a<<" and "<<b<<" is "<<sum<<"\n";return0;}

// This program adds two numbers and prints their sum, variation 1#include<iostream>#include<ostream>usingnamespacestd;intmain(){inta=123,b(456),sum=a+b;cout<<"The sum of "<<a<<" and "<<b<<" is "<<sum<<endl;return0;}
Retrieved from "https://en.wikibooks.org/w/index.php?title=C%2B%2B_Programming/Code/Variables/Examples&oldid=3227736"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp