Wednesday 5 April 2017

C Program to Check a Number is Strange or Not

Program :-


#include <stdio.h>
#include <math.h>
main(){
    int temp, num , count = 0,sum = 0,rem;
    printf("enter the number : ");
    scanf("%d",&num);
    temp = num;
    while(num > 0){
        num = num / 10;
        count++ ;
    }
    for(num =  temp ; num > 0 ; num = num /10)
    {
        rem = num % 10;
        sum = sum + pow(r,count);
     }
     if ( sum == temp)
         printf("\n number is strange");
     else
         printf("\n number is not strange");
 }

Output:-

enter the number :
12
number is no strange


No comments:

Post a Comment

How to Invert an SVG image using CSS ?

You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...