Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
static void Main(string[] args)
        {
            int n, m, c, a;
            n = Convert.ToInt32(Console.WriteLine());
            a = n;
            {
                m = n % 10;
                a = n % 10;
            }
            while(n != 0)
            {
                c--;
                m = n % 10;
                n = n / 10;
                a = a + m * Math.Pow(10,c);
                Console.ReadKey();
            }
        }
Posted
Updated 7-Dec-14 8:49am
v2
Comments
CHill60 7-Dec-14 14:19pm    
What is the error?

You are using Console.WriteLine which is for writing output to the console. You want Console.ReadLine, for reading input from the console.
C#
n = Convert.ToInt32(Console.ReadLine());
 
Share this answer
 
oh ,
What a mistake !

and this Error :
C#
a = a + m * Math.Pow(10,c);
 
Share this answer
 
Comments
CHill60 7-Dec-14 14:19pm    
If you want to respond to a post use the "Reply" or "Have a Question or Comment?" links as appropriate - that way the poster will be notified of your response.
The error you are getting is
Quote:
Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
because math.Pow() returns a double and you are trying to directly assign the results into an int
Try using
double a;

You are also attempting to use an uninitialized variable c - try
int n, m, c = 0;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900