adspace
Write a program to know whether the input number is an armstrong number.
Answer Posted / Abhinav Awasthi
Here's an example of a simple C program that checks if a number is an Armstrong number. Note that this program assumes the input number to be a positive integer less than 1000 for efficiency.n```n#include <stdio.h>nvoid armstrong(int n){ // function to check armstrong numbertint i, sum = 0, temp = n;n while (temp > 0){ntsum += (temp % 10) * (temp % 10) * (temp % 10);ntemp /= 10;n}n if (sum == n) printf("%d is an Armstrong number.", n);n else printf("%d is not an Armstrong number.", n);n}nint main(){n int num; /* input number */nprintf("Enter a positive integer less than 1000: ");nscanf("%d", &num);narmstrong(num);nreturn 0;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
swap 2 numbers without using third variable?
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
Do you know the difference between malloc() and calloc() function?
What are pointers? What are different types of pointers?
How do you convert strings to numbers in C?
Explain the difference between null pointer and void pointer.
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
What are compound statements?
ATM machine and railway reservation class/object diagram
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
Is int a keyword in c?
How do you determine the length of a string value that was stored in a variable?