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 :: Futter Square Button 
C :: how to combine strings in c 
C :: get last char string c 
C :: addition in c 
C :: multiplicationin c 
C :: c program to find minimum of 4 numbers using conditional operator in c 
C :: Graphics in C Draw A Line 
C :: for loop in c 
C :: function for calculate the average and standard deviation of table 
C :: bitwise operators in c 
C :: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 
C :: input array elements in c 
C :: C Programming to swap two variables 
C :: typescript class as function parameter 
C :: The fscanf and fprintf functions 
C :: functions in c 
C :: Bootstrap textarea from 
C :: c check if character is an alphabet 
C :: highest common factor algorithm in c 
C :: c concatenate and allocate string 
C :: transfer function exponent matlab 
C :: C program to input the month number and output the month name using switch statement 
C :: getchar c 
C :: how to check the word is present in given char array in c 
C :: bool c++ 
C :: c defined value sum 
C :: C How to define a union? 
C :: fine print serial key 
C :: find all hyperlinks <a in p tag 
C :: Talk about the difference between call by reference and call by value and in C language with example? 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =