C++ Programming using string manipulation and counting digit Problem example question with Solution
- What will be
the output of this code,
cout<<"*";
cout.width(5);
cout<<123<<"*"
<<123<<"*"<<endl;
cout<<"*"<<setw(5)<<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!='.');
|
0 comments:
Post a Comment