Related to c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Related to c

Pattern to print 555555555 544444445 543333345 543222345 543212345 543222345 543333345 544444445 555555555 The program should be generalised for any value of n Please help

25th Feb 2020, 1:35 PM
Sooraj m
Sooraj m - avatar
4 Answers
+ 1
link your attempt to your question, click on the + icon and then code then my code
25th Feb 2020, 1:37 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
Sooraj m You might wanna look at this, it's the same pattern works, just in different language. Next time maybe search before posting? 👌 https://www.sololearn.com/Discuss/2097280/?ref=app
25th Feb 2020, 1:50 PM
Ipang
0
I have my attempt program with me
25th Feb 2020, 1:36 PM
Sooraj m
Sooraj m - avatar
0
I divided the output area into 2 halves each 3 parts so in total 6 parts then solved the problem Here's my code #include<stdio.h> int main() { int N, i, j; printf("Enter N: "); scanf("%d", &N); for(i=N; i>=1; i--)//UPPER HALF { for(j=N; j>i; j--)//1st {printf("%d", j); } for(j=1; j<=(i*2-1); j++)//2nd {printf("%d", i); } for(j=i+1; j<=N; j++)//3rd {printf("%d", j); } printf("\n");//new line } for(i=1; i<N; i++)//LOWER HALF { for(j=N; (j-1)>i; j--)//4th {printf("%d", j); } for(j=0; j<=(i*2-1); j++)//5th {printf("%d", i+1); } for(j=i+1; j<=N; j++)//6th {printf("%d", j); } printf("\n");//new line } return 0; } And it works and gives desirable output you can put any value of n and get what output you wanted in the question Click the links below to see the images and understand better ![program with output](https://i.stack.imgur.com/Rxsyk.jpg) ![Divided the OUTPUT into 6 parts](https://i.stack.imgur.com/q89u0.jpg)
28th Jan 2022, 5:33 PM
Satish kumar Patra