answersLogoWhite

0


Best Answer

#include<stdio.h>

main()

{

int i,j,k,n;

printf("Enter the number of lines");

scanf("%d",&n);

for(i=n;i>=0;i--)

{

for(k=n-i;k>0;k--)

{

printf(" ");

}

for(j=i-1;j>=0;j--)

{

printf("%2d",i);

}

printf("\n");

}

}

User Avatar

Wiki User

โˆ™ 11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

โˆ™ 11y ago

The following example shows one possible solution.

Example code:

#include

int main()

{

using namespace std;

int x = 0;

bool bRepeat = true;

while( bRepeat )

{

cout << "Enter a 4 digit number:\t";

if( bRepeat = (!( cin >> x ) x < 1000 x > 9999 ))

{

cin.clear();

cin.ignore(numeric_limits::max(), '\n');

cout << "Not a valid 4 digit number. Try again.\n" << endl;

}

}

cout << x << " in reverse is:\t";

while( x )

{

cout << x % 10;

x /= 10;

}

cout << endl;

return(0);

}

Example output:

Enter a 4 digit number: 12345

Not a valid 4 digit number. Try again.

Enter a 4 digit number: abcd

Not a valid 4 digit number. Try again.

Enter a 4 digit number: 1234

1234 in reverse is: 4321

This answer is:
User Avatar

User Avatar

Wiki User

โˆ™ 14y ago

Check this link

http://www.mycplus.com/featured-articles/print-pyramids-and-diamonds-in-c-language/

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that inputs four digits numbers like 1234 from user and then display it in reverse order in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

10.) A two-digit number is prime. When you reverse the digits, that number is also prime. What could the number be List three possibilities.?

Some numbers that you can get when you reverse the digits and they are still prime numbers are: 403 รท 13 = 31 2,701 รท 37 = 73 1,207 รท 17 = 71


Write a program that inputs four digits numbers like 1234 from user and then display it in reverse order in c language?

# include&lt;stdio.h&gt; # include&lt;conio.h&gt; void main() { int n; printf("enter the number"); scanf("%d",&amp;n); while(n&gt;0) { s=n%10; printf("%d",s); n=n/10; } getch(); }


How man odd numbers between 100 and 500 remain the same when the digits are written in reverse order?

20


Does a calculator display the exact values of all rational numbers?

No. For example, 1/3 = 0.333333333...(repeats forever). The calculator can only display finitely many digits.


What is 72 reverse the digits divide by 3?

72 reverse the digits divide by 3 = 24


What does it mean to reverse the digits in a number?

Instead of reading the numbers from left to right (1234) read them from right to left (4321).


How many two-digit prime numbers can you find that are still prime when you reverse the digits?

61 42 56 89


Does a calculator display the exact values of all irrational numbers?

No. An irrational number is one that does not repeat or finish, and a calculator cannot display millions of digits like an irrational number would have.


Why is it sometimes when you add 2 numbers in scientific notation in your calculator the result is just greater of the two numbers?

This happens because the contribution of the smaller number is lost in the trailing decimal digits. Suppose you had a calculator that could display 10 digits. Suppose you tried to add 123,456.789 and 0.000 000 12 The true answer is 123,456.789 000 12 but, since you can only display 10 digits, the answer shows as 123,456.7890 which is the larger number. The exact details will depend on the number of displayed digits.


What is the largest number you can actually calculate?

There is no upper limit to numbers, there are some astronomical numbers with more digits than the universe has atoms (See Graham's number) used in math. On many calculators, the largest number it can calculate is limited by the number of digits your calculator can display. If it can display 12 digits, the largest number you can calculate on it is 999,999,999,999. The scientific calculators which support scientific notation can usually calculate numbers up to 9.999999 x 1099. Some high-tech ones can go up to 9.99999 x 10999. On the other hand, I use a professional program used to crunch numbers and the largest number it says it can express is 1.920224672692357 x 10646456887 (or 22147483296). Not that I think I would need to use such a large number any time soon.


How many numbers is ten digits?

10 digits are numbers in the billions.


How many digits numbers each less than 500 can be formed from the digits 13467 if repetitions is allowed?

There are 5 numbers of 1 digit, 25 numbers of 2 digits, and 75 numbers of 3 digits. This makes 105 numbers in all.