Skip to content

Commit

Permalink
Practical file questions
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed Oct 5, 2018
1 parent 4908aec commit 91d8db0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Binary file not shown.
36 changes: 36 additions & 0 deletions pointers/new_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
using namespace std;
struct student{
int roll;
char name[30];
float fees;
};

int main(){
student *s;
cout<<"\n\n\n Size of s :"<<sizeof(s);

s = new(student);

cout<<"\n Enter Roll :";
cin>>s->roll;

cout<<"\n Enter name :";
cin>>s->name;
cout<<"\n Enter fees :";
cin>>s->fees;

cout<<"\n\n\n Size of s :"<<sizeof(s);

cout<<"\n Roll No :"<<s->roll;
cout<<"\n Name :"<<s->name;
cout<<"\n fees :"<<s->fees;

delete(s);

cout<<"\n Roll No :"<<s->roll;
cout<<"\n Name :"<<s->name;
cout<<"\n fees :"<<s->fees;

return 0;
}
17 changes: 17 additions & 0 deletions pointers/self_referenceial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<iostream>
using namespace std;

struct student{ //self referenceial structure
int roll;
char name[30];
float fees;
student *ptr;
};

int main(){

student
return 0;
}


26 changes: 26 additions & 0 deletions structure_pointer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<iostream>
using namespace std;
struct student{
int roll;
char name[30];
float fees;
};

int main(){
student s ={10,"Swapnil",3456.96};
cout<<"\n Roll No :"<<s.roll;
cout<<"\n Name :"<<s.name;
cout<<"\n fees :"<<s.fees;

cout<<"\n\n\n Size of s :"<<sizeof(s);

student *s1 = &s;

cout<<"\n Roll No :"<<s1->roll;
cout<<"\n Name :"<<s1->name;
cout<<"\n fees :"<<s1->fees;

cout<<"\n Size of s1 :"<<sizeof(s1);

return 0;
}

0 comments on commit 91d8db0

Please sign in to comment.