Program to find single digit number from double.
Example: input --> 89
output-> 8 + 9 = 17
output-> 1 + 7 = 8 (single digit)
(It was given in Mid-term Exam in my First term)
#include<iostream>
#include<conio.h>
using namespace std;
int n, a, b, c, d, e;
int main()
{
cout << "Put any two digit number = ";
cin >> n;
while (n > 10){
a = n % 10;
b = n / 10;
c = a + b;
cout << b << " + " << a << " = " << c << "\n";
n = c;
}
_getch();
}
Example: input --> 89
output-> 8 + 9 = 17
output-> 1 + 7 = 8 (single digit)
(It was given in Mid-term Exam in my First term)
#include<iostream>
#include<conio.h>
using namespace std;
int n, a, b, c, d, e;
int main()
{
cout << "Put any two digit number = ";
cin >> n;
while (n > 10){
a = n % 10;
b = n / 10;
c = a + b;
cout << b << " + " << a << " = " << c << "\n";
n = c;
}
_getch();
}
No comments:
Post a Comment