C Language Nested Loops Set 13

Get the following output:

25 20 15 10 5
20 15 10 5
15 10 5
10 5
5

Source code: Using for loop

#include<stdio.h>
int main()
{
	int i,j;
	for(i=5;i>=1;i--)
	{
		for(j=i;j>=1;j--)
		{
			printf("%d ",j*5);
		}
		printf("\n");
	}
	return(0);
}

Source code: Using while loop

#include<stdio.h>
int main()
{
	int i=5,j;
	while(i>=1)
	{
		j=i;
		while(j>=1)
		{
			printf("%d ",j*5);
			j--;
		}
		
		printf("\n");
		i--;
	}
	return(0);
}

Get the following output:

* * * * *
* * * *
* * *
* *
*

Source code: Using for loop

#include<stdio.h>
int main()
{
	int i,j;
	for(i=5;i>=1;i--)
	{
		for(j=i;j>=1;j--)
		{
			printf("* ");
		}
		printf("\n");
	}
	return(0);
}

Source code: Using while loop

#include<stdio.h>
int main()
{
	int i=5,j;
	while(i>=1)
	{
		j=i;
		while(j>=1)
		{
			printf("* ");
			j--;
		}
		
		printf("\n");
		i--;
	}
	return(0);
}

Get the following output:

            1
         1 2
      1 2 3
   1 2 3 4
1 2 3 4 5

Source code: Using for loop

#include<stdio.h>
int main()
{
	int i,j,k,n=5;
	for(i=1;i<=5;i++)
	{
		for(k=1;k<=n;k++)
		printf("  ");
		for(j=1;j<=i;j++)
		{
			printf("%d ",j);
		}
		printf("\n");
		n--;
	}
	return(0);
}

Source code: Using while loop

#include<stdio.h>
int main()
{
	int i=1,j,k,n=5;
	while(i<=5)
	{
		k=1;
		while(k<=n)
		{
			printf("  ");
			k++;
		}
		j=1;
		while(j<=i)
		{
			printf("%d ",j);
			j++;
		}
		
		printf("\n");
		i++;
		n--;
	}
	return(0);
}