Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created folder for Structure #596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<bits/stdc++.h>
using namespace std;

// stducture Declaration

struct studentDetails // struct is used to define a stucture
{ // studentDetails is structure type
int roll;
string name; // structure memebers
int age;

};
int main()
{
struct studentDetails stud; // structure variable declaration
stud.age=22;
stud.name="Mimo Patra"; // accessing structure member using structure variable
stud.roll=153;

// printing structure members

cout<<" Structure Mmbers: "<<endl;
cout<<"Name = "<<stud.name<<endl;
cout<<"Roll = "<<stud.roll<<endl;
cout<<"Age = "<<stud.age<<endl;
return 0;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<bits/stdc++.h>
using namespace std;
struct numbers{
int a;
int b;
}x, y; // sturcture variable declaration can also be done this way
int main()
{
x.a = 10; // intializing structure member of x
x.b = 20;

y = x ; // assigning one structure to another

// printing y structure variable members

cout<<"Structure y Members: "<<endl;
cout<<"A = "<<y.a<<endl;
cout<<"B = "<<y.b<<endl;
return 0;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<bits/stdc++.h>
using namespace std;
struct pass
{
int number;
}arr[3];
int main()
{
int i ; // for iterating the loop
// using for loop to initializing all arr member element
cout<<"Enter Numbers to Initialize array structure members: "<<endl;
for(i = 0; i<3; i++)
{
cin>>arr[i].number;
}
cout<<endl;
cout<<"Printing all the structure array members: \n";
for(i = 0; i<3; i++)
{
cout<<arr[i].number<<endl;
}

return 0;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<bits/stdc++.h>
using namespace std;
struct numbers
{
int num;
}var;
void pass(int num) // function to pass the structure member and print
{
cout<<"Passed number: "<<num<<endl;
}
int main()
{
var.num=20;
pass(var.num); // passing structure member num
return 0;
}
Binary file not shown.
24 changes: 24 additions & 0 deletions Structures/Stucture Baics/Structure Function/bPassingStructure.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<bits/stdc++.h>
using namespace std;

//structure
struct details{
long phnNo;
};

void myFun(struct details go); // function prototype declaration

// main function
int main()
{
struct details ph;
ph.phnNo=1234567;
myFun(ph); // passing entire structure to myFun function

return 0;
}

void myFun(struct details go)
{
cout<<" Phone Number: "<<go.phnNo; // printing phone number
}
Binary file not shown.