Search
 
SCRIPT & CODE EXAMPLE
 

C

armstrong number 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

Armstrong 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 :: c 2d array dimensions 
C :: Call by reference to pass an array to the function in C- 
C :: search array element in c 
C :: nested loop in c 
C :: A binary tree whose every node has either zero or two children is called 
C :: console log observable data 
C :: c number to string 
C :: c how to check a palindrome string 
C :: read from a file c 
C :: get last char string c 
C :: C read a character 
C :: Graphics in C Draw A Line 
C :: downgrade chrome to previous stable version in linux 
C :: add char to char array c 
C :: set value of boolean in c 
C :: what is string::npos 
C :: celsius to fahrenheit formula 
C :: The fscanf and fprintf functions 
C :: identifier bool is undefined in c 
C :: how to compareTo in java 
C :: DrawText() raylib 
C :: print to console in c 
C :: variable swap in c 
C :: c program to implement mv command 
C :: C fscanf ignore commas 
C :: c defined 
C :: c comment 
C :: node in c 
C :: c read file from command line 
C :: recursion function bangla 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =