Answers for "how to add amount digit c++"

1

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;
   }
Posted by: Guest on April-06-2021
0

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;
}
Posted by: Guest on January-31-2022

Code answers related to "how to add amount digit c++"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language