Home » C++ Programming

Write C++ Program to Find Quotient and Remainder

Published on 21-Dec-2021 14:21:21
In this example, you will learn to find the quotient and remainder of a given dividend and divisor. In this program, the user is asked to enter two integers (divisor and dividend) and the quotient and the remainder of their division is computed. To compute quotient and remainder, both divisor and dividend should be integers. Program :  #include <iostream> using namespace std; int main() { int divisor, divi... Read More

Write C++ Program to Add Two Numbers

Published on 21-Dec-2021 13:11:20
In this program, user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen. #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 sumOfTwoNumb... Read More

Write C++ Program to Print Number Entered by User

Published on 21-Dec-2021 13:01:07
In this example, you'll learn to print the number entered by a user using C++ cout statement. Program : #include <iostream> using namespace std; int main() { int number; cout << "Enter an integer: "; cin >> number; cout << "You entered " << number; return 0; } Output : Enter an integer: 23 You entered 23 Explanation : This program asks the user to enter a number.... Read More

Write a program in C++ to print Hello World

Published on 21-Dec-2021 12:06:30
Program : To print hello world using C++ // Your First C++ Program #include int main() { std::cout << "Hello World!"; return 0; } Output : Hello World! Explanation: 1. // Your First C++ Program In C++, any line starting with // is a comment. Comments are intended for the person reading the code to better understand the functionality of the program. It is completely ignored by the C++ compiler. 2. #inclu... Read More