Question

Write a program that declares an initializes two variables a & b with the values your...

Write a program that declares an initializes two variables a & b with the values your choice, use pointer to those variables

and perform, addition, subtraction and multiplication: Print the results.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
int main()
{
//declaration of two variables and pointers to those variables
int firstnum, secondnum, *p, *q;
int sum, sub, mul;
  
printf("Enter the value of first number:\n");
scanf("%d", &firstnum);
printf("Enter the value of second number:\n");
scanf("%d", &secondnum);
  
p = &firstnum;
q = &secondnum;
  
//perform Addition, Subtraction and Multiplication
sum = *p + *q;
sub = *p - *q;
mul = *p * *q;
  
//print the results
printf("Addition: Addition of entered numbers = %d\n",sum);
printf("Subtraction: Subtraction of entered numbers = %d\n",sub);
printf("Multiplication: Multiplication of entered numbers = %d\n",mul);
return 0;
}

Output:-

Osaved main.c 2 int main) gcc version 4.6.3 Enter the value of first number: Enter the value of second number: share 1 #inclu

Add a comment
Know the answer?
Add Answer to:
Write a program that declares an initializes two variables a & b with the values your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT