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.
1
Expert's answer
2013-03-29T06:22:04-0400
//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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS