Skip to content

Instantly share code, notes, and snippets.

@Redeem-Grimm-Satoshi
Created March 25, 2020 17:51
Show Gist options
  • Save Redeem-Grimm-Satoshi/b7cbb5acdd95a76ebdc101a2c53d4e76 to your computer and use it in GitHub Desktop.
Save Redeem-Grimm-Satoshi/b7cbb5acdd95a76ebdc101a2c53d4e76 to your computer and use it in GitHub Desktop.
Compute Powers Of 2
/**
*Author: Redeem Grimm
*File Name: PowersOf2.c
*Purpose: Computes The Powers Of Two
**/
#include<stdio.h>
int main(){
//variables
int base,exponent,count=0,Power=1;
//prompting and getting input from user
printf("Enter Base: ");
scanf("%d",&base);
printf("Enter Exponent: ");
scanf("%d",&exponent);
printf("Here Are The First %d Powers Of %d:\n",exponent,base);
//loop
while(count<=exponent-1){
printf("%d^%d=%d\n",base,count,Power);
Power*=base;
//increment
count++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment