-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cc8f3b
commit f1bf5b5
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# Data-Structure | ||
|
||
> Here we use C / C++ / Python to implement some data structures. Notes from W3Schools. | ||
## Table of Contents | ||
|
||
- [Structure](#Structure) | ||
- [Pointer](#Pointer) | ||
|
||
## [Structure](https://www.w3schools.com/cpp/cpp_structs.asp) | ||
|
||
> [Example C program](./Structure/structure.c) | ||
Structure is a user-defined data type in C which allows to combine data items of different kinds. | ||
|
||
## Pointer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Example of a C program that uses a structure | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
// Define a structure | ||
struct Student { | ||
char name[50]; | ||
int age; | ||
float marks; | ||
}; | ||
|
||
int main() { | ||
// Declare a structure variable | ||
struct Student student1; | ||
|
||
// Assign values to student1 | ||
strcpy(student1.name, "John"); | ||
student1.age = 21; | ||
student1.marks = 88.5; | ||
|
||
// Print student1 information | ||
printf("Student 1\n"); | ||
printf("Name: %s\n", student1.name); | ||
printf("Age: %d\n", student1.age); | ||
printf("Marks: %.2f\n", student1.marks); | ||
|
||
return 0; | ||
} |