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

Describe the My Computer and My Documents folders; identify the elements that are present in every Window.

2592


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

2424


How stl is different from the c++ standard library?

1280


What is a stl vector?

1361


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

2948


What is meant by stl in c++?

1209


Why should a c++ programmer be interested in stl?

1151


i wanted to know about questions about c,c++ , which is required for placements.... im a fresher

2265


What is stl in oop?

1269


What is stl in c++ with example?

1215


What are the various types of stl containers?

1242


What are the different types of stl containers?

1206


write a program that will accept a number and print.its equivalent in words the maximum input number is 9999

3084


Explain stl.

1417


Who created stl?

1265