0
How to print user input in last line of this program ? Thank for help 😊
2 ответов
+ 4
Abhay mishra 
Assign n to a temp variable then print that temp variable in the last line.
Or instead of using original variable in while loop you can use temp variable.
int temp = n;
Now use this temp in while loop
while (temp != 0) {
}
+ 1
Your code is OK but the input value n become 0 (n=0).Reason , this variable was changed by calculating in while loop until 0.                
To show user input value , add one more int  variable : (int num) and assign n value to it. That means  your code after modify:
 int n , remainder , reverse = 0 ;
int num; // Add new variable
    printf("enter your value = ") ;
    scanf("%d" , &n) ;
    num = n; // assign n value
    while(n != 0){
          remainder = n % 10 ;
          reverse = reverse * 10 + remainder ;
          n = n / 10 ; 
    }
    //printf("\n The mirror value of %d is %d" , n , reverse) ; // replace n by num
   printf("\n The mirror value of %d is %d" , num, reverse) ;
    return 0 ;
hop to help you





