Question
I am currently learning about pointers in C programming. I need to make a program with two functions - one which asks the user for
I am currently learning about pointers in C programming. I need to make a program with two functions - one which asks the user for two numbers- and one which calculates the sum and product of those two numbers. I need help in making the second function. The second function will use pointers to calculate the sum and product and it will be called "calculateData". I need help using pointers to calculate the sum and product. Here is my code so far-
#include
void askData (float *n1 , float *n2);
int main(void) { float num1, num2 ,sum, product;
askData (&num1 , &num2);
printf(" %f , %f", num1,num2);
return 0; }
void askData (float *n1 , float *n2) { float num1, num2; printf("Enter a number:\t"); scanf("%f", &num1);
printf("Enter a number:\t"); scanf("%f", &num2);
*n1 = num1; *n2 = num2;
}
Please explain your code for the second function (which variables you called, why you called them etc.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started