SHARE
TWEET

Untitled

a guest Feb 18th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <locale.h>
  3.  
  4. int pot(int base, int expo) {
  5.     if(expo < 1)
  6.         return true;
  7.     else
  8.         return base*pot(base,expo-1);
  9. }
  10.  
  11. int somaN(int A, int N) {
  12.     int result = A, i = 0;
  13.     do {
  14.         result = result + A;
  15.         i++;
  16.     }  while(i < N);
  17.     return result;
  18. }
  19.  
  20. int main() {
  21.     int A, N;
  22.     /* Set the locale to the environment default */
  23.     setlocale (LC_ALL, "");
  24.    
  25.     printf("Dê o número e seu expoente inteiros:\n");
  26.     scanf("%d%d",&A,&N);
  27.     printf("O número %d elevado à %d é igual a: %d\n", A, N, pot(A,N));
  28.     printf("O número %d somado %d vezes é igual a: %d\n", A, N, somaN(A,N));
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top