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"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment