Question #39207

Write a program which asks for a positive integer n and outputs 2 raised to the power of n.
1

Expert's answer

2014-02-18T11:53:35-0500
#include <stdio.h>
int main() {
    int output, index;
    scanf("%d", &index);
    output = 1;
    for (int i = 0; i < index; i++) {
        output *= 2;
    }
    printf("%d\n", output);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS