0:20 AM 2008-2009 question 5 |
write a program that reads a sequence of integers ,, when positive number many asterisks are to be printed ,, when negative number printed out numerically . no number will be greater than 99
#include"stdio.h"
main()
{
int i, n, val, j;
printf("enter number of terms : ");
scanf("%d", &n);
for(i=1;i<=n;i++){
printf("enter value for term %d : ", i);
scanf("%d", &val);
if(val<=99){
if(val>0){
for(j=1;j<=val;j++)
printf("*");
printf("\n");
}
else
printf("%d\n", val);
}else
printf("greater than 99 .. error\n");
}
getch();
return 0;
}
|
|
Total comments: 0 | |