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; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment