
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program to find greater value between a^n and b^n in C++
In this tutorial, we will be discussing a program to find greater value between a^n and b^n.
For this we will be provided with three numbers. Our task is to calculate a^n and b^n and return back the greater of those values.
Example
#include <bits/stdc++.h> using namespace std; //finding the greater value void findGreater(int a, int b, int n){ if (!(n & 1)) { a = abs(a); b = abs(b); } if (a == b) cout << "a^n is equal to b^n"; else if (a > b) cout << "a^n is greater than b^n"; else cout << "b^n is greater than a^n"; } int main(){ int a = 12, b = 24, n = 5; findGreater(a, b, n); return 0; }
Output
b^n is greater than a^n
- Related Articles
- Find value of a and b."\n
- Find the resistance between A and B."\n
- If $n(A)=30, n(B) = 45, n(A \cup B) = 65$ then find $n(A \cap B)$, $n(A-B)$ and $n(B-A)$.
- Find N Arithmetic Means between A and B using C++.
- Find N Geometric Means between A and B using C++.
- In the figure, $a$ is greater than $b$ by one third of a right-angle. Find the values of $a$ and $b$."\n
- Program to find number not greater than n where all digits are non-decreasing in python
- Number of nodes greater than a given value in n-ary tree in C++
- Convert the following LEX program into Lexical Analyzer.\nAUXILIARY DEFINITIONS\n −\n −\n −\nTRANSLATION RULES\n a{ }\n abb{ }\n a*b+
- Find value of (n^1 + n^2 + n^3 + n^4) mod 5 for given n in C++
- Program to find N-th term of series a, b, b, c, c, c…in C++
- Find N % (Remainder with 4) for a large value of N in C++
- Count smaller numbers whose XOR with n produces greater value in C++
- Program to find trailing zeros in factorial of n in C++?\n
- C++ Program to find out the minimum difference value in n integer pairs

Advertisements