hamaXD

CPT lab03-01

Sep 4th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include<stdio.h>
  2. #define NUM 5
  3.  
  4. int sum(int *p, int *q);
  5. int main(){
  6.     int i, a[NUM];
  7.     for(i = 0; i < NUM; i++){
  8.         printf("N%02d:", i + 1);
  9.         scanf("%d", &a[i]);
  10.     }
  11.     printf("=%d\n", sum(&a[0], &a[NUM]));
  12.     return 0;
  13. }
  14. int sum(int *p, int *q){
  15.     int i=0,temp=0;
  16.     for(i=0;i<NUM;i++){
  17.         if(*(p+i)!=*q){
  18.             temp+=*(p+i);
  19.         }
  20.     }
  21.     return temp;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment