Help with this C coding

Home Forums C Programming Help with this C coding

This topic contains 2 replies, has 3 voices, and was last updated by  Adetutu 9 years, 1 month ago.

  • Author
    Posts
  • #2158

    KalaLindsey
    Member

    help write an application in C that asks user about a number and computes the 2n (two to the power of n). Print result to the screen.

  • #3484

    try:

  • #3485

    Adetutu
    Participant

    I hope this is program of you assignment. :lol: Any way If you want to calculate 2 to power n(2^n) Please try this piece of code.

    /***********************************************
    Program to Calculate 2 to power n (2^n)
    ***********************************************/
    #include
    int main()
    {
    int n, i , pow = 1;

    printf(“Enter the number (n):: “);
    scanf(“%d” , &n);
    for(i = 0; i < n; i++)
    {
    pow = pow * 2;
    }
    printf(“Result is :: %d”, pow);
    }

    Please feel to revert back.
    Thanks
    Gaurav

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble