Learn C with example
Enter a number and print Star line in Reverse Order
In this example we are going to print star line in
reverse order.
In this example in first line we are printing *
followed by n-1 spaces, in second line * followed by n-2 spaces ,so on..
Source Code of Example
#include<stdio.h>
#include<conio.h> /* * */
void main() /* * */
{ /* * */
int i,j,k,n; /* * */
clrscr(); /* * */
printf("Enter a number\t");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
printf(" ");
printf("*");
printf("\n");
}
getch();
}
|
Output Of Example
Enter a number 5
*
*
*
*
*
|