Sunday, 26 September 2021

WAP to print of digits of a entered number.

// WAP to print of digits of a entered number

#include <iostream>

#include<cstdlib>

using namespace std;


int main() {

    string str; 

    cout<<"Enter a number: "<<endl;

    cin>>str;

    int sum = 0;

    for (int i=0; i<str.length(); i++) {

        sum += str[i] - '0';

    }

    cout<<"Sum of all digit: "<<sum<<endl;

}


Featured post

In all other cases the driver is not insured. If the marital status, sex and age of the driver are the inputs, write a program to determine whether the driver is to be insured or not.

  #include #include int main() { char ms;   printf("Is Driver married (Y/N): ");  scanf("%c",&ms);   if(ms=='y&#...

Popular Posts