Search
 
SCRIPT & CODE EXAMPLE
 

C

armstrong number using function in c

#include<stdio.h>
#include<conio.h>
void arm(int a);
int main()
{
	int a;
	printf("			Enter a number
			 ");
	scanf("%d",&a);
	arm (a);
	getch();
	return 0;
}
void arm(int a)
{
	int b,sum,remainder;
	b=a;
	while (a>0)
	{
		remainder=a%10;
		sum=sum+(remainder*remainder*remainder);
		a=(a-remainder)/10;
	}
	if (b==sum)
	{
		printf("	
It is armstrong number
");
	}
	else
	{
		printf("
	It is not armstrong number
");
	}
}
Comment

armstrong number in c

#include<stdio.h>
void main(){
    int num, cNum, rem, sum;
    printf("Enter a number = ");
    scanf("%d",&num);   //153
    sum = 0;

    cNum = num; 
    while(cNum != 0){
        rem = cNum % 10;
        sum = sum + (rem * rem * rem);
        cNum = cNum / 10;
    }

    if(num == sum){
        printf("Armstrong");
    }
    else{
        printf("Not Armstrong");
    }
}
Comment

PREVIOUS NEXT
Code Example
C :: how to read character from a string in c 
C :: get current used proxy windows 7 
C :: c for schleife 
C :: pass the pointer to the function 
C :: dart in android studio 
C :: find smallest number in array in c 
C :: c integer to string 
C :: check if the c code is a palindrome 
C :: svg not loading in chrome 
C :: ROUNDING decimal number in C 
C :: right side of div 
C :: how to sort assending in c 
C :: how to modulo in c without % 
C :: C Passing string to a Function 
C :: how to reverse a string in c 
C :: initialize array c 
C :: putchar in c 
C :: Bitwise Operators in C/C++ 
C :: convert c program to assembly language online 
C :: typedef vs #define 
C :: windows forms picturebox change image 
C :: number pattern in c 
C :: class in oops 
C :: best approach c menu terminal 
C :: pointer arithmetic on Arrray in c 
C :: check if string contains a character in c 
C :: nested while loop in c 
C :: size of int in c 
C :: c convert float to int 
C :: promt user input C 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =