Write a program in C in which add and subtract pointer of the same type.

 TASK-

Write a program in C in which add and subtract pointer of the same type.


To understand pointers click: 👉👉 Pointers

CODE:

#include<stdio.h>

int main(){

int num1,num2,final;

int *n1,*n2; //declaration of pointers

n1=&num1; //& is basically pointing the address which is being stored in n1

n2=&num2;

printf("Enter Two numbers: ");

scanf("%d",n1);

scanf("%d",n2);

printf("\nThe summing gives:%d",*n1+*n2); 

//To excess the value on a particular address put *before pointer.

printf("\nThe subtraction gives:%d",*n1-*n2);

getchar();

return 0;

}

Expected Output:





NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

1 Comments

Post a Comment
Previous Post Next Post