write a program that input four digit number and find how
many 7 that number contains
Answer Posted / kumar
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
cout << "Enter a 4 digit number with '7' in it:";
cin >> str;
str.resize(4);
cout << "The 4 digit numebr you have entered is:" << str
<<endl;
int ipos = 0, count =0;
ipos = str.find_first_of('7');
while (ipos!=-1)
{
count ++;
ipos = str.find_first_of('7',(ipos+1));
}
if (count)
cout <<"Number of '7' in the string: "<<count<<endl;
else
cout <<"There are no 7's in the string entered"<<endl;
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
draw a flowchart that accepts two numbers and checks if the first is divisible by the second.
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
How connect plc and pc through software
How do I convert a stl file?
What is a stl vector?
Explain stl.
Who created stl?
please visit this site you'll find my question this is my homework please answer it if you can http://easyscience.org/ib/lofiversion/index.php/t36168.html
In what scenario does the Logical file and Physical file being used?
What is stl in c++ with example?
help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase
How is stl different from c++ standard library?
To modify an, existing worksheet. What steps are involved for: 1. Inserting and deleting rows and columns. 2. Printing cell formulas 3Jld displayed values 3. Using the page setup command
What is meant by stl in c++?
sir please send me bpcl previous question papers