Labels

Wednesday, June 9, 2010

ENTER Exactly 3 no

enter exactly 3 no:


#include

int main() {
char buffer[BUFSIZ];
int x, y, z;

printf("Enter exactly three numbers on one line:\n");
for(;;) {
int bogus;

if(!fgets(buffer, sizeof buffer, stdin)) return 1;

if(sscanf(buffer, "%d%d%d%d", &x, &y, &z,&bogus) != 3) {
printf("Hey. I said *exactly* three numbers.\n");
}
else break;
}

printf("Product %d*%d*%d = %d\n", x, y, z, x*y*z);

return 0;
}
~

1 comment: