Get the following output:
25 20 15 10 5
25 20 15 10
25 20 15
25 20
25
Source code: Using for loop
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
{
printf("%d ",j*5);
}
printf("\n");
}
return(0);
}
Source code: Using while loop
#include<stdio.h>
int main()
{
int i=1,j;
while(i<=5)
{
j=5;
while(j>=i)
{
printf("%d ",j*5);
j--;
}
printf("\n");
i++;
}
return(0);
}
Get the following output:
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
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);
}
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);
j--;
}
printf("\n");
i--;
}
return(0);
}
Get the following output:
10 8 6 4 2
8 6 4 2
6 4 2
4 2
2
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*2);
}
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*2);
j--;
}
printf("\n");
i--;
}
return(0);
}




