Q13 Write a program to implement subtraction of a number to a pointer.

Admin

 

Write a program to implement subtraction of a number to a pointer.

#include <stdio.h>
#include <stdlib.h>
int main()
{
    int num1,num2;    
    int *ptr1,*ptr2;   
    int sub;            
    printf("Please enter value for num1: "); 
    scanf("%d",&num1);                 
    printf("Please enter value for num2: "); 
    scanf("%d",&num2);
    ptr1=&num1;
    ptr2=&num2;
    sub=*ptr1 - *ptr2;
    printf("Subtraction of the two integer values is: %d",sub);
    return 0;
}

Output

Please enter value for num1: 90
Please enter value for num2: 89
Subtraction of the two integer values is: 1

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.