C - Write program to display the powers of 2, showing all values from 2^0 through 2^10

Requirements

Write a program that displays the powers of 2, showing all values from 2^0 through 2^10.

Hint

Use math pow function.

Demo

#include <stdio.h>
#include <math.h>

int main()/*from  w  w  w  . j a v a  2 s  .c  o m*/
{
    float twos;

    puts("The Holy Numbers of Computing");
    for(twos=0;twos<=10;twos++)
        printf("2^%.0f = %.0f\n",twos,pow(2,twos));
    return(0);
}

Result

Related Exercise