C Program
/* C - Power of a Number */ #include <stdio.h> int main(){ long long base, exp, result = 1; scanf("%lld%lld", &base, &exp); for(long long i=0;i<exp;i++) result *= base; printf("%lld", result); return 0; }
C Output
Input: 2 5 Output: 32
C++ Program
// C++ - Power of a Number #include <bits/stdc++.h> using namespace std; int main(){ long long base, exp, result = 1; cin >> base >> exp; for(long long i=0;i<exp;i++) result *= base; cout << result; }
C++ Output
Input: 3 4 Output: 81
JAVA Program
// Java - Power of a Number import java.util.*; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long base = sc.nextLong(), exp = sc.nextLong(), result = 1; for(long i=0;i<exp;i++) result *= base; System.out.print(result); } }
JAVA Output
Input: 5 3 Output: 125
Python Program
# Python - Power of a Number base, exp = map(int, input().split()) result = 1 for _ in range(exp): result *= base print(result)
Python Output
Input: 7 2 Output: 49
In-Depth Learning – Entire Concept in Paragraphs
Social Plugin