Write a C program that defines and initialize an integer and a floating point nu
ID: 3824348 • Letter: W
Question
Write a C program that defines and initialize an integer and a floating point number and defines two pointers to point to those variables respectively. The program then uses the pointers only to display the contents of the variables. Also, the program should use the pointers to increase the value of the integer by 10 and multiply the floating point number by 3 and display the changed values of those variables on the screen. In the last step the program may use either the variable names or their pointers.
Thanks!
Explanation / Answer
#include <stdio.h>
int main(void) {
// your code goes here
int a = 10;
float f = 20;
float *f1 = &f;
int *a1 = &a;
printf(" original value of int variable is : %d ",*a1);
printf(" original value of float variable is: %f ",*f1);
*a1 = *a1+10;
*f1 = *f1*3;
printf(" changed value of int variable is : %d ",*a1);
printf(" changed value of float variable is: %f ",*f1);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.