English

Write a Program to Generate Following Patterns. 1 2 3 3 4 5 6 7 8 9 - Structured Programming Approach

Advertisements
Advertisements

Question

Write a program to generate following patterns. 

1
2 3
3 4 5
6 7 8 9 

Solution

#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
j=i;
for(k=1;k<=i;k++)
{
printf(“%d”,j++);
}
printf(“\n”);
}
return 0;
}
Output:
1
2 3
3 4 5
6 7 8 9
shaalaa.com
Control Structures - Nested Control Structure
  Is there an error in this question or solution?
2018-2019 (December) CBCGS

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×