Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Addition of Two Numbers using Pointer

    C Programming Examples


    This program performs addition of two numbers using pointers.

    In this program I have used two integer variables x, y and two pointer variables p and q.

    Firstly I have assign the addresses of x and y to p and q respectively and then assign the sum of x and y to variable sum. & is address of operator and * is value at address operator.

    Example:

    #include <stdio.h>
    
    int main()
    {
        int first, second, *p, *q, sum;
        
        printf("Enter two integers to add\n");
        scanf("%d%d", &first, &second);
        
        p = &first;
        q = &second;
        
        sum = *p + *q;
        
        printf("Sum of entered numbers = %d\n",sum);
        
        return 0;
    }

    Program Output:

    add-numbers-using-pointers-c



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.