-
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
f1bf5b5
commit d1e78b0
Showing
2 changed files
with
34 additions
and
2 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
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,29 @@ | ||
// Example of a C++ program that uses a structure | ||
#include <iostream> | ||
#include <string> | ||
using namespace std; | ||
|
||
// Define a structure | ||
struct Person { | ||
string name; | ||
int age; | ||
float salary; | ||
}; | ||
|
||
int main() { | ||
// Declare a structure variable | ||
Person p1; | ||
|
||
// Assign values to members of the structure variable | ||
p1.name = "John"; | ||
p1.age = 25; | ||
p1.salary = 25000.50; | ||
|
||
// Display the values of the structure variable | ||
cout << "Person Details" << endl; | ||
cout << "Name: " << p1.name << endl; | ||
cout << "Age: " << p1.age << endl; | ||
cout << "Salary: " << p1.salary << endl; | ||
|
||
return 0; | ||
} |