C program--write a program to find whether the given number of
three digits is an integer such that the sum of the cubes of its
digits is equal to the number itself. For example, 371 is since
3**3 + 7**3 + 1**3 = 371.
Output:
Enter a number, or * to quit : 432
4**3 + 3**3 + 2**3 is not = 432
Enter a number, or * to quit : 371
3**3 + 7**3 + 1**3 is = 371
Enter a number, or * to quit : *
Please help..
#include <stdio.h>
int main()
{
int number, oriNumber, rem, result = 0;
printf("Enter a number, or * to quit:
");
scanf("%d", &number);
oriNumber = number;
while (oriNumber != 0)
{
rem =
oriNumber%10;
result +=
rem*rem*rem;
oriNumber /= 10;
}
if(result == number)
printf("%d**3 + %d**3 +
%d**3 is not = %d ",number);
else
printf("%d**3 + %d**3 +
%d**3 is = %d.",number);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
int number, oriNumber, rem, result = 0;
char str[50];
while(1){
result = 0;
printf("Enter a number, or * to quit: ");
scanf("%s", &str);
if(str[0] == '*'){
break;
}
number = atoi(str);
oriNumber = number;
while (oriNumber != 0)
{
rem = oriNumber%10;
if(oriNumber == number){
printf("%d**3 ",rem);
}
else{
printf("+ %d**3 ",rem);
}
result += rem*rem*rem;
oriNumber /= 10;
}
if(result == number)
printf("is = %d\n",number);
else
printf("is not = %d\n",number);
}
return 0;
}


C program--write a program to find whether the given number of three digits is an integer...
C program--write a program to find whether the given number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is since 3**3 + 7**3 + 1**3 = 371. Output: Enter a number, or * to quit : 432 4**3 + 3**3 + 2**3 is not = 432 Enter a number, or * to quit : 371 3**3 + 7**3 + 1**3 is = 371...
Write a JAVA program to check whether a given number is an Armstrong number. An Armstrong number is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.
Hello, I need help with the following C code. This program asks the user to enter three numbers and outputs the sum on the screen , all im trying to do is have the program reprompt the user for a number if anything other than a number is entered for each of the entries. I wanted to use do while for each of the functions but that did not work for example: Enter Number 1: 2 Enter Number 2: Hello...
C program help: Write a C program that uses three functions to perform the following tasks: – The first function should read the price of an item sold at a grocery store together with the quantity from the user and return all the values to main(). example: #include void getInput(int *pNum1, int *pNum2); // note: *pNum1 & *pNum2 are pointers to ints int main () { int numDucks,numCats; getInput(&numDucks, &numCats); // passing addresses of num1 & num2 to...
Please do both parts (in Java); thanks!
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3^3 + 7^3 + 1^3 = 371. Draw the flowchart and write a Java code to find ALL Armstrong number in the range of 0 and 999. You should write your code in two ways: (Yes as if you are...
Please write MIPS program that runs in QtSpim (ex: MipsFile.s) Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base and print out the decimal value; you must implement a function (which accepts a base and an address for a string as parameters, and returns the value) and call the function from the main program. The base will be given in decimal and will...
Write a C program which calculates how many digits a number has and prints each digit in reserve order with space in between(no space after the last digit). The number > 0 and has no more than 5 digits. (optional] It is better to write two functions. One is designed for printing number in reverse order and the other is for counting the number of digits. Given that the value of number (which is an int variable) is 12345, the...
Write a MATLAB program that implements the algorithm designed in the Topic 1 "Non-Linear Flowchart" and "Creating a Flowchart" assignments previously implemented in C. Compare and contrast the C and MATLAB versions of your codes. convert this to a matlab program #include <stdio.h> int main() { int a; printf("Enter first number: "); scanf("%d", &a); int b; printf("Enter second number: "); scanf("%d", &b); int limit; printf("Enter limit: "); scanf("%d", &limit); printf("\nFirst number: %d\n", a); printf("Second number: %d\n", b); int c; c...
Solve using C programming
3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...
In the Source Folder (src) of this project create a new C source file called "gcd.c". Once again, copy the contents of the "main.c" file above into the "gcd.c" source file. Modify this program to NOT ask the user to input the second Positive Integer, if the user has entered a program terminating value for the "first" input Postitive Integer. #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { //============================== setbuf(stdout, NULL); // turns standard output buffering off int...