answersLogoWhite

0


Best Answer

This was checked for C++ using VS2008.

#include

using std::cin;

using std::cout;

using std::endl;

int main()

{

cout << endl << "Enter of digits in the last number of the patter "

<< endl << "(should be odd number, if you enter even number N," << endl << "the answer will have N - 1 digits in the last number): ";

int numElem = 0;

cin >> numElem;

cout << endl << "Pattern:" << endl;

for (int i = 1; i <= numElem; i += 2)

{

for (int j = 1; j <= i; j++)

{

cout << j;

}

cout << endl;

}

system("PAUSE");

return 0;

}

For just C you might want to use something like (not tested):

#include

int main()

{

cout << endl << "Enter of digits in the last number of the patter "

<< endl << "(should be odd number, if you enter even number N,"

<< endl << "the answer will have N - 1 digits in the last number): ";

int numElem = 0;

cin >> numElem;

cout << endl << "Pattern:" << endl;

for (int i = 1; i <= numElem; i += 2)

{

for (int j = 1; j <= i; j++)

{

cout << j;

}

cout << endl;

}

system("PAUSE");

return 0;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

class logic

{

public static void main(String args[])

{

int a,b;

for(a=1;a<=5;a++)

{

for(b=1;b<=a;b++)

System.out.print(b+" ");

}

}

}

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

System.out.println("1234 123 12 1 12 123 1234");

Or write two nested loops for the descending sequence, and then again two nested loops for the ascending sequence, printing one digit at a time, and using print() instead of println().

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

public class apples {

public static void main(String argc[]) {

System.out.println("12321");

}

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

for (int i=0; i<5; ++i) { System.out.print (i+1);

System.out.print (' ');

System.out.print (5-i);

System.out.print (' ');

}

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Use a nested loop:

int x, y;

for (x=1; x<=5; ++x)

for (y=1; y<=x; ++y)

System.out.print(y);

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you please tell me the c program to print the following pattern... 1 123 12345 1234567?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you please get this program off of my computer programs?

please just take this program off of my computer . I need to take care of things and I can not do them if this program is in operation. a thank you


Can you all unlock all cheatcodes?

No. Sometimes you need a program. But PLEASE PLEASE PLEASE PLEASE PLEASE do not download those programs.


Can you please give c program for sudoku?

No


What methods can be used to construct a pattern of 10 numbers for which it would mathematically impossible to predict the 11th term?

Please don't write "the following" if you don't provide a list.


What accurately descibes antoninus pius as emperor in ancient rome?

Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?Please restate your question. What are the "following"? What are the choices? Why don't you simply read your history book?


Which of the following locations would be on the equator?

Please include the "following locations" in your question.


Describe the structure of a c program?

Yes, please do.


What did the algonquians learn and how do they learn?

The program has to answer my question please!


How do you request a birthday greeting from California governor?

You say the following: "Please, Swartznegger, please!"


What is object program in computer programming?

I ALSO WANT TO KNOW!what is meant by object program?PLEASE TELL ME THE ANSWER.


Please puctuate the following sentence- Give you that disk please.?

That sentence makes no sense, but, &quot;Give you that disk, please.&quot;


Which of the following contibuted to the fall of the western roman empire?

Please restate your question. What are the "following"?