68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #63022 in C for yahya

Question #63022
Write a C program in which you will:
1. Prompt user to enter values the following variables: an integer, a double, and a character.
2. Create a pointer for each of the variable.
3. Using only the pointers, increase the variables by 1.
4. Print out the value and the address of each variable.
Name your program task1.c
Output of your program should look like this:
hb117@uxb4:~$ gcc -Wall task1.c -o task1
hb117@uxb4:~$ ./task1
Please enter an integer, a double and a character:
99 1.3 a
100 0x7ffcc9aeaadc
2.300000 0x7ffcc9aeaae0
b 0x7ffcc9aeaadb
Expert's answer
#include <stdio.h>

int main(int argc, char *argv[])
int a;
char c;
double d;
int* p_a = &a;
char* p_c = &c;
double* p_d = &d;
printf("Please enter an integer, a double and a character:");
scanf("%d %lf %c", &a, &d, &c);
*p_a += 1;
*p_c += 1;
*p_d += 1;
printf("%d %p\n", *p_a, p_a);
printf("%lf %p\n", d, p_d);
printf("%c %p\n", c, p_c);
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions