Please fill in the blanks from 13 to 58 for C /* This program will do some basic programming using pointers. All will be written in main. Declare 2 integers and 2 floats and initialize them (no need for user inputs): i1,i2,f1,f2 Print all 4 variables’ */ /*Pointers Basic*/ #include int main() { printf("------------------------------------------------------------------------------------------------------------\n"); printf("Note: Pointers' values should be the same as the address of the variable it points to.\n"); printf("\tThe de-reference values of the pointers should be the same as the value of the variable it points to.\n"); printf("\tPointer pi1 points to i1. Pointer pi2 points to i2. Pointer pf1 points to f1. Pointer pf2 points to f2.\n"); printf("\tWhen printing values for the floats using the variables themselves or through de-referencing pointers, \ remember to round them to 3 decimal places.\n"); printf(" ------------------------------------------------------------------------------------------------------------\n\n"); // Declare 2 ints and 2 floats int i1, i2; //the integers float f1, f2; // the floats // Initialize all 4 variables i1 = 3, i2 = -100; f1 = 2.4564; f2 = -34.21234; //Print all four variables' values //Round the float to 3 decimal places printf("\nPrinting values:\n"); printf("i1 = %d, i2 = %d, f1 = %.3f, f2 = %.3f.\n", i1, i2, f1, f2); //Print all four variables' addresses printf("\nPrinting addresses:\n"); printf("i1's = __13__, i2's = __14__, f1's = __15__, f2's = __16__.\n", __17__, __18__, __19__, __20__); //Declare 2 pointer-to-int and 2 pointer-to-float // name 2 pointer-to-int pi1 and pi2 // name 2 pointer-to-float pf1 and pf2 __21__ __22__, __23__; //pointer-to-int pi1, pi2 __24__ __25__, __26__; //pointer-to-float pf1, pf2 //Initialize pointer-to-int pointers __27__ = __28__; //first pointer-to-int points to i1 __29__ = __30__; //second int pointer points to i2 //Initialize pointer-to-float __31__ = __32__; //first pointer-to-float points to f1 __33__ = __34__;//second float pointer points to f2 printf("\nPrinting pointers' addresses:\n"); printf("pi1's = __35__, pi2's = __36__, pf1's = __37__, pf2's = __38__.\n", __39__, __40__, __41__, __42__); printf("\nPrinting pointers' values:\n"); printf("pi1's = __43__, pi2's = __44__, pf1's = __45__, pf2's = __46__.\n", __47__, __48__, __49__, __50__); printf("\nPrinting pointers' de-reference values:\n"); printf("de-ref pi1 = __51__, de-ref pi2 = __52__, de-ref pf1 = __53__, de-ref pf2 = __54__.\n",__55__, __56__, __57__, __58__); return 0; }
Please fill in the blanks from 13 to 58 for C
/* This program will do some basic
Declare 2 integers and 2 floats and initialize them (no need for user inputs): i1,i2,f1,f2
Print all 4 variables’ */
/*Pointers Basic*/
#include<stdio.h>
int main()
{
printf("------------------------------------------------------------------------------------------------------------\n");
printf("Note: Pointers' values should be the same as the address of the variable it points to.\n");
printf("\tThe de-reference values of the pointers should be the same as the value of the variable it points to.\n");
printf("\tPointer pi1 points to i1. Pointer pi2 points to i2. Pointer pf1 points to f1. Pointer pf2 points to f2.\n");
printf("\tWhen printing values for the floats using the variables themselves or through de-referencing pointers, \
remember to round them to 3 decimal places.\n");
printf(" ------------------------------------------------------------------------------------------------------------\n\n");
// Declare 2 ints and 2 floats
int i1, i2; //the integers
float f1, f2; // the floats
// Initialize all 4 variables
i1 = 3, i2 = -100;
f1 = 2.4564; f2 = -34.21234;
//Print all four variables' values
//Round the float to 3 decimal places
printf("\nPrinting values:\n");
printf("i1 = %d, i2 = %d, f1 = %.3f, f2 = %.3f.\n", i1, i2, f1, f2);
//Print all four variables' addresses
printf("\nPrinting addresses:\n");
printf("i1's = __13__, i2's = __14__, f1's = __15__, f2's = __16__.\n", __17__, __18__, __19__, __20__);
//Declare 2 pointer-to-int and 2 pointer-to-float
// name 2 pointer-to-int pi1 and pi2
// name 2 pointer-to-float pf1 and pf2
__21__ __22__, __23__; //pointer-to-int pi1, pi2
__24__ __25__, __26__; //pointer-to-float pf1, pf2
//Initialize pointer-to-int pointers
__27__ = __28__; //first pointer-to-int points to i1
__29__ = __30__; //second int pointer points to i2
//Initialize pointer-to-float
__31__ = __32__; //first pointer-to-float points to f1
__33__ = __34__;//second float pointer points to f2
printf("\nPrinting pointers' addresses:\n");
printf("pi1's = __35__, pi2's = __36__, pf1's = __37__, pf2's = __38__.\n", __39__, __40__, __41__, __42__);
printf("\nPrinting pointers' values:\n");
printf("pi1's = __43__, pi2's = __44__, pf1's = __45__, pf2's = __46__.\n", __47__, __48__, __49__, __50__);
printf("\nPrinting pointers' de-reference values:\n");
printf("de-ref pi1 = __51__, de-ref pi2 = __52__, de-ref pf1 = __53__, de-ref pf2 = __54__.\n",__55__, __56__, __57__, __58__);
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images