FREE E LEARNING PLATFORM
HOMEEXCEPTIONSOOPSJVMINTRO
 

Find Largest of Two Numbers(Entered by User)

noidatut course




An integer number is called Armstrong number if sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3*3*3 + 7*7*7 + 1*1*1 = 371.

Lets write a program to check whether the input number is armstrong number using user-defined function. If you are looking for a program to check armstrong number using loop then see: C++ Program to check Armstrong number using for loop.

Example: Check whether input number is Armstrong Number or not

#include <iostream>  
using namespace std;
    int main()  {
      int num1, num2;
      cout<<"Enter first number:";
       cin>>num1;
      cout<<"Enter second number:";
       cin>>num2;
      if(num1>num2)      {
  	cout<<"First number "<<num1<<" is the largest"; 
     }
      else
      {
  	cout<<"Second number "<<num2<<" is the largest";  
    }      return 0;
  }

Output

noidatut course






Leave Comment