sum of digits in c++
int x, s = 0;
cout << "Enter the number : ";
cin >> x;
while (x != 0) {
s = s + x % 10;
x = x / 10;
}
sum of digits in c++
int x, s = 0;
cout << "Enter the number : ";
cin >> x;
while (x != 0) {
s = s + x % 10;
x = x / 10;
}
How to add numbers in c++
#include <iostream>
int main() {
std::cout << "Hello & Welcome to Adding Calculator Application.n";
// Create the Variables (FirstNumber & SecondNumber)
int FirstNumber = 0, SecondNumber = 0;
// Get the First Number
std::cout << "Please enter your first number: ";
std::cin >> FirstNumber;
// Get the Second Number
std::cout << "Please enter your second number: ";
std::cin >> SecondNumber;
// Add the two numbers
int Sum = FirstNumber + SecondNumber;
std::cout << "The Sum of the two numbers is: "<< Sum;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us