In this tutorial, we will discuss a concept of C program to add two numbers using pointer variable
In the C programming language, we can use the pointer variable to add two numbers
In this article, we are going to learn how to Display the sum of two numbers using the pointer variable
Program 1
#include <stdio.h> #include <stdlib.h> int main() { int num1,num2; //1 int *ptr1,*ptr2; //2 int sum; //3 printf("Please enter value for num1: "); //4 scanf("%d",&num1); //5 printf("Please enter value for num2: "); //6 scanf("%d",&num2); //7 ptr1=&num1; //8 ptr2=&num2; //9 sum=*ptr1+*ptr2; //10 printf("Sum of the two integer values is: %d",sum); //11 getch(); return 0; }
When the above code is executed, it produces the following results
Please Enter value for num1: 46 Please enter value for num2: 64 Sum of the two integer values is: 110
Methods
Similar post
C program find the sum of two numbers using the function
C program find the sum of two numbers using recursion
C program to find the product of two numbers using the pointer
Suggested for you
Input-output function in C language
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Python full Pyramid star pattern program In this tutorial, we will discuss the concept of…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…