+ 1

Write a program in C to print the pattern?

1 4 6 9 11 13 17 19 21 23 I recently saw a meme about this on Facebook.I have tried alot to solve this but i can't find the appropriate logic to solve this. Attempt: https://code.sololearn.com/cEEkYR5RaFwb/?ref=app

29th May 2020, 4:30 PM
Saurav Lamichhane
Saurav Lamichhane - avatar
5 Respostas
+ 2
This is something you're suppose to solve yourself. You don't take a picture of a puzzle and ask people on the internet to solve it for you, so why do it here? You don't learn anything by asking others to solve it for you. EDIT: Thank you for posting some code. But this isn't really a programming challenge, it's a logic puzzle. Before you start writing any code, try and figure out the pattern.
29th May 2020, 6:04 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
Please show us your attempt(s), then we can give you a hint what's wrong. https://www.sololearn.com/discuss/1316935/?ref=app
29th May 2020, 6:11 PM
HonFu
HonFu - avatar
+ 1
rather complicated, indeed... this works https://code.sololearn.com/caI7BsQnm4w4/?ref=app
29th May 2020, 7:00 PM
Bilbo Baggins
Bilbo Baggins - avatar
+ 1
#include<iostream> using namespace std; int main() { int an,i,j; for(i=1;i<=4;i++,cout<<endl) { an=((i*i*i)+(11*i)-6)/6; for(j=0;j<i;j++) { cout<<an+j*2<<" "; } } return 0; }
13th Jun 2020, 3:42 PM
Varshni N
Varshni N - avatar
0
#include <iostream> using namespace std; int main() { int row; cout<<" Enter the number of rows "<<endl; cin>>row; for ( int i=1;i <=row;i++){ int n = (i*i*i + 11*i - 6) / 6; for( int j=1;j <=i;j++){ cout<< n << " "; n=n+2; } cout<<endl; } return 0; } This C++ Code might help
28th Mar 2021, 5:48 AM
Henry Singh
Henry Singh - avatar