C Online Compiler
Example: C Program to Perform all Arithmetic Operations using Pointers
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Perform all Arithmetic Operations using Pointers #include <stdio.h> int main() { int p, q; int sum, sub, mul, mod; float div; int *x, *y; // These are the pointer variables // It will take two integer numbers printf("Enter any two positive integer numbers:\n"); scanf("%d%d", &p, &q); x = &p; y = &q; // It will perform all arithmetic operations sum = *x + *y; sub = *x - *y; mul = *x * *y; div = (float)*x / *y; mod = *x % *y; // It will print the final output of the program printf("\n"); printf("Addition of %d + %d = %d\n", *x, *y, sum); printf("Subtraction of %d - %d = %d\n", *x, *y, sub); printf("Multiplication of %d * %d = %d\n", *x, *y, mul); printf("Division of %d / %d = %f\n", *x, *y, div); printf("Modulus of %d %% %d = %d\n", *x, *y, mod); return 0; }
6 8
Output
Clear
ADVERTISEMENTS