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




