FY_BCA_C_SLIP_3



/* slip no : 3_1 write a C prog to check wheather given no is amstrong or not */

#include<stdio.h>
#include
int main()
{
      int no,rem,orgno,sum;
      clrscr();
      printf("\n Enter no :");
      scanf("%d",&no);
      orgno=no;
      sum=0;
      while(no>0)
      {
            rem=no%10;
            sum=sum+rem*rem*rem;
            no=no/10;
      }

      if(sum==orgno)
      printf("\n%d is amstrong no ",orgno);
      else
      printf("\n NOT amstrong");
      getch();
}

No comments:

Post a Comment