0% found this document useful (0 votes)
47 views

C++ "Hello, World!" Program: #Include

This document contains 5 C++ programs: 1) A "Hello World" program that prints "Hello World"; 2) A program that takes a number from the user and prints it; 3) A program that adds two numbers; 4) A program that finds the quotient and remainder of two numbers; 5) A program that prints the size of basic data types (char, int, float, double) on the system. Each program uses basic C++ input/output functions and data types to demonstrate a simple programming concept.

Uploaded by

Amal Jesudas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

C++ "Hello, World!" Program: #Include

This document contains 5 C++ programs: 1) A "Hello World" program that prints "Hello World"; 2) A program that takes a number from the user and prints it; 3) A program that adds two numbers; 4) A program that finds the quotient and remainder of two numbers; 5) A program that prints the size of basic data types (char, int, float, double) on the system. Each program uses basic C++ input/output functions and data types to demonstrate a simple programming concept.

Uploaded by

Amal Jesudas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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;

You might also like