Sample Qustion 1

Write a C++ program to calculate the sum of the digits of a number until the number is a single digit.

#include <iostream>
using namespace std;

int main()
{
    int number ;
    cout << "enter number :" << endl;
    cin >> number;
    int res;

    if(number)
        res = number % 9 == 0 ? 9 : number % 9 ;
    else
        res = 0;


    cout<<res;
 
    return 0;
}


download file  cpp file

do you have any qustion please comment 



click the advertisement to help for me ....



Comments

Popular posts from this blog

Sample Qustion 11

Sample Qustion 5