Write a C++ program where you should take the first element of an array named \"
ID: 3825007 • Letter: W
Question
Write a C++ program where you should take the first element of an array named "fantastic_numbers" and implement a function called check() which takes the array fantastic_numbers. The method check() checks whether all elements can be divided or not. If yes, print return TRUE from the function or return FALSE. Write a program in C++ to check whether a user given integer number is Armstrong number or not. Re-write the Armstrong program using function and class. Define a class called MyClass which has a method investigate_number() which does the Armstrong check. Write a C++ program to calculate roots of a quadratic equation. Use functions
Explanation / Answer
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int InputNum, num, Reminder, sum = 0,digit;
cout << "Enter a positive integer: ";
cin >> InputNum;
num = InputNum;
while(num != 0)
{
digit = num % 10;
sum += digit * digit * digit;
num /= 10;
}
if(sum == InputNum)
cout << InputNum << " Given Number is an Armstrong number.";
else
cout << InputNum << " Given Number is not an Armstrong number.";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.