Tuesday 13 December 2011

program to add two integers using pointers

#include<stdio.h>
#include<malloc.h>
main()
{
        int *a,*b,c;
        a=(int*) malloc(sizeof(int));
        b=(int*) malloc(sizeof(int));
        printf("\n enter two numbers: ");
        scanf("%d %d",a,b);
        c=*a+*b;
        printf("\n the addition of the two numbers is %d",c);
}

No comments:

Post a Comment