Number and asterisks
C Program that read five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the number seven, it should print *******
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, num;
printf("Enter 5 numbers between 1 and 30:\n");
for (i = 0; i < 5; i++)
{
printf("Number - %d\t:",i+1);
scanf("%d", &num);
for (j = 0; j < num; j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output
Enter 5 numbers between 1 and 30:
Number - 1 :15
***************
Number - 2 :25
*************************
Number - 3 :12
************
Number - 4 :3
***
Number - 5 :15
***************