

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


int main() // main entry point into the program { // start of main int i,i,input; // variable declaration
// counter variable declaration int count0,count1,count2,count3,count4,count5,count6,count7,count8,count9; // counter initialization to zero count0=count1=count2=count3=count4=count5=count6=count7,count8=count9=0; printf("enter number (0-9)\n"); scanf("%d",&input); // user input integer i=1; // loop counter initialization while(i<=20) // loop condition that check for maximum 20 inputs { // switch statement to check each user input against case 0- switch(input){ case 0: count0++; // Increment statement if your input 0 break; // skipping other cases case 1: count1++; break; case 2: count2++; break; case 3: count3++; break; case 4: count4++; break; case 5: count5++; break; case 6: count6++; break; case 7: count7++; break; case 8: count8++; break; case 9: count9++; break;
default: printf("input out of range enter (0-9)\n"); } // end of switch statement printf("enter number (0-9)\n"); scanf("%d",&input); // user input i++; // increment of loop counter } // end of while loop
// displaying user final summary printf("0=%d,1=%d,2=%d,3=%d,4=%d,5=%d,6=%d,7=%d,8=%d,9=%d\n",count ,count1,count2,count3,count4,count5,count6,count7,count8,count9);
} // end of main program