Friday, April 4, 2014

Write a program that repeatedly collects positive integers(only)


Write a program that repeatedly collects positive integers from the user, stopping when the user enters a negative number or zero.
+/- Click and see the code that is about the article.
#include 
int main() {

int number,product=1,counter=0; 
for (counter=0;counter<=10;counter++) 
{
 counter=1;
 printf("Enter a number : ");
 scanf("%d",&number);
 if (number>0)
 {
  product=number*product;
  continue;
  
 }
 else break;
 
}
 printf("%d",product);
}

No comments:

Post a Comment