0% found this document useful (0 votes)
2 views3 pages

Assigment:22: Step 1 Step 2 Step 3 Step 4

The document provides an assignment to write a C program that checks if a given number is an Armstrong number. It includes an algorithm outlining the steps, a flowchart for visual representation, and the complete C program code. An example input/output is also provided, demonstrating the program's functionality with the number 153.

Uploaded by

kanishkbabugarh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Assigment:22: Step 1 Step 2 Step 3 Step 4

The document provides an assignment to write a C program that checks if a given number is an Armstrong number. It includes an algorithm outlining the steps, a flowchart for visual representation, and the complete C program code. An example input/output is also provided, demonstrating the program's functionality with the number 153.

Uploaded by

kanishkbabugarh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGMENT:22

QUESTION:
Write a C program to check whether a given number is Armstrong number or not .

ALGORITHM:
STEP 1 : Start.
STEP 2: Declare n, number, r, result.
STEP 3: Get the required positive number and store in n.
STEP 4: Use while loop until original number is not zero.
r= number %10
result =result+ (r*r*r)
number =number /10
STEP 5: Check if result and n are equal
STEP 6: Print the appropriate output
STEP 7: Stop

FLOWCHART:
Start
CREATED BY PANKAJ
Declare variable:n,num,r,result=0

Print: “Enter a positive integer:”

Input: n

False
while(num!=0)

True
Calculate & initialize
r=num%10
result=result+(r*r*r)
Number=num%10

FALSE True
if(result==n)

Print:“%d is an
Armstrong number”,n

Print: “%d is not an Armstrong


number”,n

Stop

PROGRAM:
CREATED BY PANKAJ
#include<stdio.h>
#include<conio.h>
void main()
{
int n,num, r, result=0;
clrscr();
printf("Enter a positive integer: ");
scanf("%d", &n);
num=n;
while(num!=0)
{
r=num %10;
result=result+(r*r*r);
number =num / 10;
}
if(result==n)
printf("%d is an Armstrong number ", n);
else
printf("%d is not an Armstrong number", n);
getch();
}

INPUT/OUTPUT:
Enter a positive integer:153
153 is an Armstrong number

CREATED BY PANKAJ

You might also like