// Lab 8, Working with structs
// Programmer : Maiar Khattab
// Editor(s) used : Code Blocks 13.12
// Compiler(s) used : Code Blocks 13.12
#include<iostream>
using std::cout;
using std::endl;
#include<cstdlib>
//struct def
struct tod
{
int hour;// the hr , 0-23
int minute;// the min, 0-59
int second;//the sec, 0-59
char descr [32];//the description of the time of day
};
//void printTod(const tod&);
int main ()
{
cout << "Lab 8, Working With structs\n";
cout << "Programmer: Maiar Khattab\n";
cout << "Editor(s) used: Code Blocks 13.12\n";
cout << "Compiler(s) used: Code Blocks 13.12\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
tod theTime[] = {{12,0,0, "noon"},
{0,0,0," midnight"},
{6,00,00," supper "},
{11,30,0,"bedtime"}};
for(int i; i <5; i++)
{
char descr [32];
cout << theTime[i].descr << " is " << theTime[i].hour << ':'
<< theTime[i].minute << ":" << theTime[i].second << endl;
}
}
IC8vIExhYiA4LCBXb3JraW5nIHdpdGggc3RydWN0cwovLyBQcm9ncmFtbWVyIDogTWFpYXIgS2hhdHRhYgovLyBFZGl0b3IocykgdXNlZCA6IENvZGUgQmxvY2tzIDEzLjEyCi8vIENvbXBpbGVyKHMpIHVzZWQgOiBDb2RlIEJsb2NrcyAxMy4xMgoKI2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIHN0ZDo6Y291dDsKdXNpbmcgc3RkOjplbmRsOwoKI2luY2x1ZGU8Y3N0ZGxpYj4KCi8vc3RydWN0IGRlZgpzdHJ1Y3QgdG9kCnsKaW50IGhvdXI7Ly8gdGhlIGhyICwgMC0yMwppbnQgbWludXRlOy8vIHRoZSBtaW4sIDAtNTkKaW50IHNlY29uZDsvL3RoZSBzZWMsIDAtNTkKY2hhciBkZXNjciBbMzJdOy8vdGhlIGRlc2NyaXB0aW9uIG9mIHRoZSB0aW1lIG9mIGRheQoKfTsKLy92b2lkIHByaW50VG9kKGNvbnN0IHRvZCYpOwppbnQgbWFpbiAoKQp7CiAgY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gLy8gRGlzcGxheSB0aGUgc2NvcmVzCiAgICBkaXNwbGF5U2NvcmVzKGhlYWQpOwoKICAgIHJldHVybiAwOwp9Cg==
#include <stdio.h>
#include <stdlib.h>
// Define the structure for a node in the linked list
struct Node {
int score;
struct Node* next;
};
// Function to add a score to the linked list
void addScore(struct Node** head, int score) {
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->score = score;
newNode->next = *head;
*head = newNode;
}
// Function to display all scores
void displayScores(struct Node* head) {
while (head != NULL) {
printf("Score: %d\n", head->score);
head = head->next;
}
}
int main() {
struct Node* head = NULL;
// Add scores
addScore(&head, 56); // Tamim
addScore(&head, 35); // Shanto
addScore(&head, 40); // Liton
addScore(&head, 60); // Mushfiq
addScore(&head, 25); // Shakib
addScore(&head, 35); // Riad
// Display the scores
displayScores(head);
return 0;
}