Answer to Question #6015 in C++ for Amedeus Simon

Question #6015
write a program that reads a list of any five numbers and counts the number of threes and sevens in the data(this is C++ question)
1
Expert's answer
2012-01-19T11:12:24-0500
#include <iostream>
using namespace std;

char str[50];
int i,k, NumOfThrees=0, NumOfSevens=0;

void count(){
cout<<"Enter a number: ";
cin>>str;
for (i=0;i<=strlen(str);i++){
& if (str[i]=='3') NumOfThrees++;
& if (str[i]=='7') NumOfSevens++;
}
}

void main(){

for (k=1;k<=5;k++) count();

cout<<"The number of threes is "<<NumOfThrees<<"\r\n";
cout<<"The number of sevens is "<<NumOfSevens<<"\r\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS