Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
sum3.c 551 Bytes
Copy Edit Web IDE Raw Blame History
Yingzhou authored 2016-03-13 14:49 . Add a sample test and its results
#include <stdio.h>
int main()
{
int n, i, sum;
void A(int *x, int *y);
printf("Enter a positive number: ");
scanf("%d", &n);
sum = 0;
i = 1;
while (i <= n)
{
A(&sum,&i);
}
printf ("sum = %d\n", sum);
printf ("i = %d\n", i);
return 0;
}
void A(int *x, int *y)
{
void add(int *a, int *b);
void inc(int *z);
add(x,y);
inc(y);
}
void add(int *a, int *b)
{
*a = *a + *b;
// return(a);
}
void inc(int *z)
{
// int add(int a, int b);
int tmp = 1;
add(z,&tmp);
}

Comment ( 0 )

Sign in for post a comment