~riderius/cpp-code

380d65aaa5846a8ec60fc901587e37f663b5b2e1 — riderius 11 days ago 1da8e8f main
digits_analysis.cpp: argv[1] can replace n

Signed-off-by: riderius <riderius.help@gmail.com>
1 files changed, 10 insertions(+), 3 deletions(-)

M digits_analysis.cpp
M digits_analysis.cpp => digits_analysis.cpp +10 -3
@@ 1,4 1,5 @@
#include <climits>
#include <cstdlib>
#include <iostream>

int SumOfDigits(int n);


@@ 7,17 8,23 @@ int MinDigit(int n);
int MaxDigit(int n);
int reverse(int n);

int main(void)
int main(int argc, char* argv[])
{
    using namespace std;

    int n;
    cin >> n;
    if(argc > 1)
        n = atoi(argv[1]);
    else {
        cout << "Enter a number: ";
        cin >> n;
        cout << endl;
    }
    cout << "Sum Of Digits: " << SumOfDigits(n) << endl;
    cout << "Number Of Zeroes: " << NumberOfZeroes(n) << endl;
    cout << "Min Digit: " << MinDigit(n) << endl;
    cout << "Max Digit: " << MaxDigit(n) << endl;
    cout << "Reverse: " << reverse(n);
    cout << "Reverse: " << reverse(n) << endl;

    return 0;
}