old is gold computer programming in C Grade-12|Qn 2

old is gold computer programming in C Grade-12|Qn 2

What is while loop statement? Write an algorithm and a C program to input number and reverse it.

For information about while loop

Click here

C program to input number and reverse it

#include<stdio.h>

#include<conio.h>

void main()

{

          int a, n, s=0;

          printf("\n Enter a number");

          scanf("%d", &a);

          while(a>0)

          {

                   n=a%10;

                   s=(s*10)+n;

                   a=a/10;

          }

          printf("\n Reverse number=%d", s);

          getch();

}

Output



 

 


Post a Comment

0 Comments