62 556
Assignments Done
98,8%
Successfully Done
In June 2018

Answer to Question #27061 in Action Script | Flash | Flex | ColdFusion for Nader Abdel Hadi

Question #27061
write a program that reads a three-digit integer number,separates the digits(using/and%),and outputs on the screen how many digit zero, digit one, and digit two the number contains.
Expert's answer
//main function
int main()
{
int coutforzero=0;//count for zero
int coutforone=0;//count for one
int coutfortwo=0;//count for two
char inputnumber[3];//arrau of three-digit integer number
printf("Enter three-digit integer number: ");//input number
scanf("%s",inputnumber);
for(int i=0;i<3;i++){
if((int)inputnumber[i]==0){
coutforzero++;//calculate number of zero
}
if((int)inputnumber[i]==0){
coutforone++;//calculate number of one
}
if((int)inputnumber[i]==0){
coutfortwo++;//calculate number of two
}
}
printf("
Number of zero %d",coutforzero);
printf("
Number of one %d",coutforone);
printf("
Number of two %d",coutfortwo);
return 0;
}


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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions