Question

3. A structure pointer is pointing to type time with 3 fields min, sec and hours...

3. A structure pointer is pointing to type time with 3 fields min, sec and hours having pointers to integers. Write the way to initialize the 2nd element to 10.

Please finish this question in C language programming

Thank you so much!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The way to initialize the 2nd element to 10 is given below:

time->sec = 10;

The complete source code for the structure pointer using main() method for testing is given below:

#include <stdio.h>

//structure
struct Time
{
int min;
int sec;
int hours;
};
int main()
{
//structure pointer declaration
struct Time *times;
  
//structure variable declaration
struct Time t;
  
//assign the structure time pointer variable
times = &t;
  
//assign value using structure pointer
times->min = 5;
times->sec = 10;
times->hours = 12;
  
//display value using pointer variable
printf("Min = %d\n", times->min);
printf("Sec = %d\n", times->sec);
printf("Hours = %d\n", times->hours);
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
3. A structure pointer is pointing to type time with 3 fields min, sec and hours...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT