Monday, 16 June 2014

C++ program to find largest digit of a number



Here is a C++ program to find largest digit of a number


 SOURCE CODE OUTPUT
#include <iostream>
using namespace std;
int main()
{
    int num,maxi=0,temp;
    cout<<"Enter the number ";
    cin>>num;
    while(num)
    {
        if(maxi<num%10)
            maxi=num%10;
        num/=10;
    }
    cout<<"Maximum digit is "<<maxi;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment