Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

draw a flowchart that accepts two numbers and checks if the first is divisible by the second.

3320


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

2589


How connect plc and pc through software

2405


How do I convert a stl file?

1031


What is a stl vector?

1154


Explain stl.

1303


Who created stl?

1099


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

2201


In what scenario does the Logical file and Physical file being used?

2774


What is stl in c++ with example?

1085


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

2319


How is stl different from c++ standard library?

1251


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

2179


What is meant by stl in c++?

1085


sir please send me bpcl previous question papers

2332