728x90 AdSpace

Latest Article

C++ using string and Count digit Problem Example Question with Solution





C++ Programming using string manipulation  and counting digit Problem example question with Solution 

  1. What will be the output of this code,

cout<<"*";
cout.width(5);
cout<<123<<"*"
    <<123<<"*"<<endl;
cout<<"*"<<setw(5)<<123
    <<"*"<<123<<"*";



*  123*123*
*  123*123*

 
 








2. Write a program that read string and count the number of digit in this string.

char ch[100];
cin>>ch;
int count=0;
for(int i=0;i<10;i++)
 if(isdigit(ch[i]))
   count++;

cout<<"Count Digit"<<count;

3. What will be the output of this code, if user enters “CS200.”?

char ch;
do{
    cin.get(ch);
    if(isdigit(ch))
     cout<<ch;
}while(ch!='.');

200

 
 
no image
  • Title : C++ using string and Count digit Problem Example Question with Solution
  • Posted by :
  • Date : 12:58
  • Labels :





  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top