Skip to main content

Reversing a number

PROCEDURE:-

      1.enter integer value n
      2.repeat  step 3 to 5 until n is greater than 0
      3. find the modulo 10 for n and store result in r
      4.print r
      5. find new value of n by dividing it by 10


CODE:-

#include<stdio.h>
void main()
{
  int n,r;
  printf(“enter value for n”);
  scanf(“%d”,&n);
  while(n>0)
  {
    r=n%10;
    printf(“%d”,r);
    n=n/10;
  }
}


Input:- enter value for n 124
Output:- 421

Comments

Popular posts from this blog

Find Value of S=ut+1/2*a*t**2.

PROCEDURE:-        1.enter values for u,a,t to find distance        2.find distance with the formulae ut+1/2at 2        3.print the above result CODE:- #include<stdio.h> #include<conio.h> void main() {   float u,t,a,S;   clrscr();   printf(“enter values u,t,a”);   scanf(“%f %f %f”, &u,&t,&a);   S=(u*t)+(0.5*a*t*t);   printf(“\n  S = %f”, S); } Input:- enter values u,t,a               U=10,t=4,a=4.9 Output:- S =79.200