#include <stdio.h>
void get_sum_diff(int x, int y, int* p_sum, int* p_diff);
int main(void)
{
int x;
int y;
int r, s;
printf("Enter an integer");
scanf_s("%d %d", &x, &y);
void get_sum_diff(x, y, &r, &s);
printf("sum of elements = %d", r);
printf ("the difference between elements = %d", s);
return 0;
}
void get_sum_diff(int x, int y, int* p_sum, int* p_diff)
{
*p_sum = x + y;
*p_diff = x - y;
}
It's a program that makes a function with a pointer as a parameter and gives the sum and the difference of the elements.
I tried to run the get_sum_diff
function in the main
function, but the &r
and &s
were red lines
They need an identifier, where is it wrong?
The problem did not occur in scanf_s, but the code below is the problem.
void get_sum_diff(x, y, &r, &s);
When using (calling) a function, it must be used without void as shown below. Note return values such as void only when declaring or defining a function; not when calling a function.
get_sum_diff(x, y, &r, &s);
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
578 Understanding How to Configure Google API Key
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.