Operations on pointers-finds the sum and difference between numbers given.
#include <stdio.h>
void update(int* a , int* b) {
int temp = *a;
*a = temp + *b;
*b = temp - *b;
if (*b < 0)
{
*b *= (-1);
}
}
int main() {
int a , b;
int* pa = &a , * pb = &b;
printf("Enter two Numbers : "); scanf("%d %d" , &a , &b);
update(pa , pb);
printf(" sum : %d\n Difference : %d" , a , b);
return 0;
}
No comments:
Post a Comment