Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdio.h>
- #include<stdlib.h>
- using namespace std;
- int main(){
- int stringLength,countr=0,flag=0;
- cout<<"Enter String length";
- cin>>stringLength;
- char stringHolder[stringLength];
- cout<<"Enter String"<<endl;
- cin>>stringHolder;
- int i = 0;
- for(i=0;i<stringLength;i++){
- int ascVal = (int) stringHolder[i];
- if(ascVal >= 48 && ascVal < 58){
- if(flag == 1){
- continue;
- }
- countr++;
- flag = 1;
- }
- else{
- flag = 0;
- }
- }
- cout<<"Number Of Digits : "<<countr;
- }
Add Comment
Please, Sign In to add comment