C++ "Hello, World!
" Program
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
C++ Program to Print Number
Entered by User
#include <iostream>
using namespace std;
int main()
int number;
cout << "Enter an integer: ";
cin >> number;
cout << "You entered " << number;
return 0;
C++ Program to Add Two Numbers
#include <iostream>
using namespace std;
int main()
int firstNumber, secondNumber, sumOfTwoNumbers;
cout << "Enter two integers: ";
cin >> firstNumber >> secondNumber;
// sum of two numbers in stored in variable sumOfTwoNumbers
sumOfTwoNumbers = firstNumber + secondNumber;
// Prints sum
cout << firstNumber << " + " << secondNumber << " = " << sumOfTwoNumbers;
return 0;
C++ Program to Find Quotient and
Remainder
#include <iostream>
using namespace std;
int main()
int divisor, dividend, quotient, remainder;
cout << "Enter dividend: ";
cin >> dividend;
cout << "Enter divisor: ";
cin >> divisor;
quotient = dividend / divisor;
remainder = dividend % divisor;
cout << "Quotient = " << quotient << endl;
cout << "Remainder = " << remainder;
return 0;
C++ Program to Find Size of int, float,
double and char in Your System
#include <iostream>
using namespace std;
int main()
cout << "Size of char: " << sizeof(char) << " byte" << endl;
cout << "Size of int: " << sizeof(int) << " bytes" << endl;
cout << "Size of float: " << sizeof(float) << " bytes" << endl;
cout << "Size of double: " << sizeof(double) << " bytes" << endl;
return 0;