Pointers in C

Write a program to implement the basic functionalities of pointers in C. A pointer in C is a way to share a memory address among different contexts (primarily functions).

Example:

Input: a = 4, b = 5
Output: 9 , 1

C Program

#include <stdio.h>
#include <math.h>
void update(int *aint *b)
{
    int cd;
    c = *a + *b;
    d = fabs(*a - *b);
    printf("%d\n%d"cd);
}

int main()
{
    int a = 4b = 5;
    int *pa = &a, *pb = &b;
    update(papb);
    return 0;
}


No comments:

Post a Comment