Home » Sometech » Write a menu driven program to check 1. sum of the digits of a number 2. reverse of the digits of a number.

Write a menu driven program to check 1. sum of the digits of a number 2. reverse of the digits of a number.

#include <stdio.h>

#include <conio.h>

void main()

{

            int num,temp,sum=0,rem,i,choice;

           clrscr();

           printf(“\nEnter the number “);

           scanf(“%d”,&num);

          printf(“\n****************************”);

           printf(“\n* 1. Sum of the digits     *”);

           printf(“\n* 2. reverse of the digits *”);

           printf(“\n* 3. Exit                  *”);

           printf(“\n****************************”);

      do

{

           printf(“\n\nEnter choice =>”);

           scanf(“%d”,&choice);

           switch(choice)

{

      case 1:

              temp=num;     

      do

{

              rem=temp%10;

              sum=sum+rem;

              temp=temp/10;

}

         while(temp!=0);

             printf(“\nSum of digits of %d is =%d”,num,sum);

             break;

      case 2:

             printf(“\nReverse of %d is =”,num);

             temp=num; 

        do

{

              rem=temp%10;

              printf(“%d”,rem);

              temp=temp/10;

}

          while(temp!=0);

              break;

       case 3: exit();

           default: printf(“\nChoice is wrong!!!”);

}

}

           while(choice<=3);

        getch();

}

 

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: