SSEC-Coding Contest Problem 1

Editorial For SSEC-Coding Contest

Problem Link:

SSEC0001

Author: Pavan Kumar

Difficulty: Easy-Medium

PREREQUISITES: Basic Maths

Problem:

Complete the function void reload (int *x, int *y) accepting two arguments, which will find sum of them, and with absolute difference of them.

Sample Input:

4
5

Sample Output:

9
1

Solution:

#include<stdio.h>
#include<stdlib.h>

void reload(int *x, int *y){
int temp = *x;
*x = *x + *y;
*y = abs(temp - *y);
}
int main(){
int x, int y;
int *px=&x, *py=&y;
scanf(ā€œ%d %dā€, &x, &y);
reload(px,py);
printf(ā€œ%d\n%dā€,x,y);
return 0;
}