Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
//Header file
#include <stdio.h>
{
//Main program 
 int main()
{
   //Declaration of variables.
   int n,r=0 ,rev;
   // Initialization of variables 
   scanf("%d",&n);
   //Processing of variables 
   r = n%10;
   rev = rev*10+r;
   n =n/10;
   //Output 
  printf ("%d",rev);
 return 0;
  }   
}   


What I have tried:

I have but getting error :expected identifier or '('before '}' token .please help me.
Posted
Updated 24-Dec-21 21:59pm

I would try to
C++
//Header file
#include <stdio.h>
{ // remove this line
//Main program 
 int main()
{
   //Declaration of variables.
   int n,r=0 ,rev;
   // Initialization of variables 
   scanf("%d",&n);
   //Processing of variables 
   r = n%10;
   rev = rev*10+r;
   n =n/10;
   //Output 
  printf ("%d",rev);
 return 0;
  }   
} // remove this line
 
Share this answer
 
Comments
CPallini 23-Sep-21 1:56am    
5.
Patrice T 23-Sep-21 3:12am    
Thank you, but 1 year old answer :)
CPallini 23-Sep-21 3:55am    
OMG!
Patrice fixed your compilation problem. However, the code, as it stands, still has flaws. See the notes below:
C
//Header file
#include <stdio.h>
//Main program 
int main()
{
   //Declaration of variables.
   int n, r=0 , rev; // Note: r is also initialised

   // Initialization of variables 

   // Note you didn't initialise 'rev' here

   scanf("%d",&n);
   //Processing of variables 
   r = n % 10;
   rev = rev * 10 + r ; // Note you are using the uninitialised 'rev'
   n =n / 10; // Note: this operation is pointless, since you didn't use 'n' afterwards
   //Output 
  printf ("%d",rev); // Note: here the output is 'unpredictable' since you've used the uninitialised 'rev'
  return 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