Mr_HO1A

CPP Solution

Oct 9th, 2018
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. using namespace std;
  5. int main(){
  6.     int stringLength,countr=0,flag=0;
  7.     cout<<"Enter String length";
  8.     cin>>stringLength;
  9.     char stringHolder[stringLength];
  10.     cout<<"Enter String"<<endl;
  11.     cin>>stringHolder;
  12.     int i = 0;
  13.     for(i=0;i<stringLength;i++){
  14.         int ascVal = (int) stringHolder[i];
  15.         if(ascVal >= 48 && ascVal < 58){
  16.             if(flag == 1){
  17.                 continue;
  18.             }
  19.             countr++;
  20.             flag = 1;
  21.         }
  22.         else{
  23.             flag = 0;
  24.         }
  25.     }
  26.     cout<<"Number Of Digits : "<<countr;
  27. }
Add Comment
Please, Sign In to add comment