Help with this C coding

Home Forums C Programming Help with this C coding

Viewing 2 reply threads
  • Author
    Posts
    • #2158
      KalaLindsey
      Participant

      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
      GWILouisaxwzkla
      Participant

      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

Viewing 2 reply threads
  • You must be logged in to reply to this topic.