Get the following output:
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
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);
}
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);
j--;
}
printf("\n");
i++;
}
return(0);
}
Get the following output:
10 8 6 4 2
10 8 6 4
10 8 6
10 8
10
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*2);
}
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*2);
j--;
}
printf("\n");
i++;
}
return(0);
}
Get the following output:
9 7 5 3 1
9 7 5 3
9 7 5
9 7
9
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*2-1);
}
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*2-1);
j--;
}
printf("\n");
i++;
}
return(0);
}




