Advertisement
Sayukoo

[Funkcja]Liczenie potegi

Oct 8th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int potega(int x,int n)
  5. {
  6.     int i;
  7.     for(i=1;i<=n;i++)
  8.     {
  9.         x*=x;
  10.     }
  11.  
  12.  return x;
  13. }
  14. int main()
  15. {
  16.     int n,x;
  17.     printf("Napisz konkretna liczbe oraz potege a program obliczy to: ");
  18.     printf("\nLiczba: "); scanf("%d",&x);
  19.     printf("Potega: ");   scanf("%d",&n);
  20.  
  21.     printf("Liczba %d do potegi %d jest rowna %d",x,n,potega(x,n));
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement