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:
thanks sir please continue it and we learn
ReplyDelete