Please fill in the blanks for C /* This function works with pointers and structures. All codes will be in main(). Define a struct time with 3 fields: hours, minutes, and seconds (all ints) in that order. */ /* Pointers and Structures*/ #include //Define a structure of type struct time struct time { __1__ hours; __2__ minutes; __3__ seconds; }; int main() { //Declare 2 struct of type struct time called t1 and t2 __4__ __5__ t1, t2; //Declare a pointer-to-struct called pt of the same type __6__ __7__ __8__; //Initialize the pointer point to t1 __9__ = __10__; //Assign values to each member. No space!! //1. using t1 variable __11__ = 3; //hours __12__ = 15; //minutes __13__ = 59; //seconds //2. Using de-referecing pointer pt and period. Remember the () __14__ = 3; //hours __15__ = 15; //minutes __16__ = 59; //seconds //Printing format: hours:minutes:seconds printf("Printing t1 using t1 variable: __17__:__18__:__19__\n", __20__, __21__, __22__); printf("Printing t1 using pt pointer: __23__:__24__:__25__\n", __26__, __27__, __28__); //Point pointer-to-struct to t2 __29__ = __30__; //Assign values to each member //using t2 variable __31__ = 11; //hours __32__ = 43; //minutes __33__ = 23; //seconds //Using arrow operator __34__ = 11; //hours __35__ = 43; //minutes __36__ = 23; //seconds //Printing format: hours:minutes:seconds printf("\nPrinting t2 using t2 variable: __137__:__38__:__39__\n", __40__, __41__, __42__); printf("Printing t2 using pt pointer: __43__:__44__:__45__\n", __46__, __47__, __48__); return 0; }
Please fill in the blanks for C
/* This function works with pointers and structures. All codes will be in main().
Define a struct time with 3 fields: hours, minutes, and seconds (all ints) in that order. */
/* Pointers and Structures*/
#include<stdio.h>
//Define a structure of type struct time
struct time
{
__1__ hours;
__2__ minutes;
__3__ seconds;
};
int main()
{
//Declare 2 struct of type struct time called t1 and t2
__4__ __5__ t1, t2;
//Declare a pointer-to-struct called pt of the same type
__6__ __7__ __8__;
//Initialize the pointer point to t1
__9__ = __10__;
//Assign values to each member. No space!!
//1. using t1 variable
__11__ = 3; //hours
__12__ = 15; //minutes
__13__ = 59; //seconds
//2. Using de-referecing pointer pt and period. Remember the ()
__14__ = 3; //hours
__15__ = 15; //minutes
__16__ = 59; //seconds
//Printing format: hours:minutes:seconds
printf("Printing t1 using t1 variable: __17__:__18__:__19__\n", __20__, __21__, __22__);
printf("Printing t1 using pt pointer: __23__:__24__:__25__\n", __26__, __27__, __28__);
//Point pointer-to-struct to t2
__29__ = __30__;
//Assign values to each member
//using t2 variable
__31__ = 11; //hours
__32__ = 43; //minutes
__33__ = 23; //seconds
//Using arrow operator
__34__ = 11; //hours
__35__ = 43; //minutes
__36__ = 23; //seconds
//Printing format: hours:minutes:seconds
printf("\nPrinting t2 using t2 variable: __137__:__38__:__39__\n", __40__, __41__, __42__);
printf("Printing t2 using pt pointer: __43__:__44__:__45__\n", __46__, __47__, __48__);
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images