-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-6-21.c
More file actions
42 lines (35 loc) · 771 Bytes
/
exp-6-21.c
File metadata and controls
42 lines (35 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*************************************************************************
> File Name: exp-6-21.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Mon Jul 10 14:51:46 2017
************************************************************************/
/*
* Write a C program to find power of any number using for loop
*
* Example
*
* Input
* Input base: 2
* Input exponent: 5
*
* Output
* 2 ^ 5 = 32
*
*/
#include <stdio.h>
int main()
{
int base, exponent;
long long power = 1;
int i;
//read base and exponent from user
printf("Enter base and exponent one by one: ");
scanf("%d%d", &base, &exponent);
for(i=1; i<=exponent; i++)
{
power *= base;
}
printf("%d ^ %d = %lld\n", base, exponent, power);
return 0;
}