daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Feb 21st, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. long double mem(void *x, int size, int arr_size)
  4. {
  5.     int i=0;
  6.     char j=0;
  7.     long double sum=0;
  8.     char *temp = (char *)x;
  9.     switch(size)
  10.     {
  11.         case sizeof(char):
  12.             {
  13.                 while (0)
  14.                 {
  15.  
  16.                 }  
  17.             }
  18.     }
  19.     i = 0;
  20.     while (i < arr_size)
  21.     {
  22.         j = j + temp[i];
  23.         i++;
  24.     }
  25.     printf("sum = %d\n", j);
  26.     while (i < arr_size)
  27.     {
  28.         sum = sum + (long double)temp[i];
  29.         i++;
  30.     }
  31.     printf("sum = %Lf\n", sum);
  32.     return sum;
  33. }
  34.  
  35. int main()
  36. {
  37.     long double sum;
  38.     char x[10] = {1,2,3,4,5,6,7,8,9,10};
  39.     sum = mem(x, sizeof(char), 10);
  40.     return 0;
  41. }
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