Skip to content

Commit f28bd65

Browse files
Update weeklycontent.html
1 parent 99bbf13 commit f28bd65

File tree

1 file changed

+83
-5
lines changed

1 file changed

+83
-5
lines changed

weeklycontent.html

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,7 @@ <h3>5. What is the purpose of the `fprintf` function in `writeStudentToFile()`?<
25362536
</div>
25372537

25382538
<div id="monday-content-week6" class="day-content day-section">
2539-
<h2>MONDAY</h2>
2539+
<h2>Monday Maverick</h2>
25402540
<div class="content-block">
25412541
<h3>How to Build Logic in Programming:</h3>
25422542
<ul>
@@ -2578,7 +2578,7 @@ <h3>File Handling in C – Interview Based Questions:</h3>
25782578
</div>
25792579
</div>
25802580
<div id="tuesday-content-week6" class="day-content day-section">
2581-
<h2>TUESDAY</h2>
2581+
<h2>Techie Tuesday</h2>
25822582
<div class="quiz-container">
25832583
<h3>File Handling in C – Interview Based Questions:</h3>
25842584
<div class="question-block">
@@ -2605,7 +2605,7 @@ <h3>File Handling in C – Interview Based Questions:</h3>
26052605
</div>
26062606
</div>
26072607
<div id="wednesday-content-week6" class="day-content day-section">
2608-
<h2>WEDNESDAY</h2>
2608+
<h2>Syntax Snapshots Wednesday</h2>
26092609
<div class="quiz-container">
26102610
<h3>File Handling in C – Interview Based Questions:</h3>
26112611
<div class="question-block">
@@ -2641,7 +2641,82 @@ <h3>File Handling in C – Interview Based Questions:</h3>
26412641
<p style="text-align: center; font-style: italic; color: #555;">CONTENT COMING SOON!</p>
26422642
</div>
26432643
<div id="friday-content-week6" class="day-content day-section">
2644-
<p style="text-align: center; font-style: italic; color: #555;">CONTENT COMING SOON!</p>
2644+
<!-- <p style="text-align: center; font-style: italic; color: #555;">CONTENT COMING SOON!</p>-->
2645+
<h2>Function Friday</h2>
2646+
<div class="content-block">
2647+
<h3>Unions in C: Memory-Efficient Type Sharing:</h3>
2648+
<p>A union is a special user-defined data type that can hold members of different data types, but only one member can hold a value at any given time. All members of a union share the same memory location, making them highly memory-efficient.</p>
2649+
</div>
2650+
<div class="content-block">
2651+
<h3>Syntax:</h3>
2652+
<pre><code>// Union declaration
2653+
union Data {
2654+
int i;
2655+
float f;
2656+
char str[20];
2657+
};</code></pre>
2658+
</div>
2659+
<div class="content-block">
2660+
<h3>Example:</h3>
2661+
<pre><code>#include &lt;stdio.h&gt;
2662+
2663+
// Define a union to store different types of data
2664+
union Value {
2665+
int intVal;
2666+
float floatVal;
2667+
char charVal;
2668+
};
2669+
2670+
int main() {
2671+
union Value val;
2672+
2673+
// Assign and print integer
2674+
val.intVal = 100;
2675+
printf("Integer value: %d\n", val.intVal);
2676+
2677+
// Assign and print float (overwrites int)
2678+
val.floatVal = 3.14;
2679+
printf("Float value: %.2f\n", val.floatVal);
2680+
2681+
// Assign and print char (overwrites float)
2682+
val.charVal = 'A';
2683+
printf("Char value: %c\n", val.charVal);
2684+
2685+
// Show memory size
2686+
printf("Size of union: %lu bytes\n", sizeof(val));
2687+
2688+
return 0;
2689+
};</code></pre>
2690+
</div>
2691+
<div class="content-block">
2692+
<h3>Output:</h3>
2693+
<code>Integer value: 100
2694+
Float value: 3.14
2695+
Char value: A
2696+
Size of union: 4 bytes</code>
2697+
</div>
2698+
<div class="quiz-container">
2699+
<h3>C Unions Basics:</h3>
2700+
<div class="question-block">
2701+
<p>1. What is a key characteristic of a C union regarding its members and memory allocation?</p>
2702+
<div class="options">
2703+
<div class="quiz-option" data-question="q1" data-value="a">A. All members have separate memory locations.</div>
2704+
<div class="quiz-option" data-question="q1" data-value="b">B. It can hold multiple member values simultaneously.</div>
2705+
<div class="quiz-option" data-question="q1" data-value="c">C. All members share the same memory location, and only one member can hold a value at a time.</div>
2706+
<div class="quiz-option" data-question="q1" data-value="d">D. Its size is the sum of the sizes of all its members.</div>
2707+
</div>
2708+
<div class="quiz-feedback"></div> </div>
2709+
2710+
<div class="question-block">
2711+
<p>2. Which of the following correctly declares a union named <strong>MyUnion</strong> with an integer member "x" and a float member "y"?</p>
2712+
<div class="options">
2713+
<div class="quiz-option" data-question="q2" data-value="a">A. MyUnion { int x; float y; };</div>
2714+
<div class="quiz-option" data-question="q2" data-value="b">B. union MyUnion { int x; float y; };</div>
2715+
<div class="quiz-option" data-question="q2" data-value="c">C. struct MyUnion { int x; float y; };</div>
2716+
<div class="quiz-option" data-question="q2" data-value="d">D. declare union MyUnion { int x; float y; };</div>
2717+
</div>
2718+
<div class="quiz-feedback"></div> </div>
2719+
</div>
26452720
</div>
26462721

26472722
</div> <!-- add week6 content before these -->
@@ -3406,7 +3481,10 @@ <h3>25. Why is `fgets()` used for reading the student name instead of `scanf("%s
34063481
// 'q1': 'your_answer_for_thursday_q1',
34073482
// 'q2': 'your_answer_for_thursday_q2'
34083483
// },
3409-
// 'friday': { /* ... */ },
3484+
'friday': {
3485+
'q1': 'c', // Tuesday Q1: malloc()
3486+
'q2': 'b'
3487+
},
34103488
// 'saturday': { /* ... */ }
34113489
},
34123490
'week7': { // Added answers for Week 7 (Mindmash Quiz 1)

0 commit comments

Comments
 (0)