Hogy-Bear

pointerpowerunlocked

Mar 12th, 2018
222
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char const *argv[]) {
  4.  
  5.   int start;
  6.   int *ptr = &start;
  7.  
  8.   int total = 0;
  9.  
  10.   printf("how many numbers would you like to add: ");
  11.   scanf("%d", &start);
  12.   for (size_t i = 0; i < start; i++) {
  13.     ptr++;
  14.     printf("please enter a number: ");
  15.     scanf("%d", ptr);
  16.     total+=*ptr;
  17.   }
  18.   printf("total is %d\n", total);
  19.  
  20.   return 0;
  21. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment