diff --git a/Notes_Assignment/Structure.pptx b/Notes_Assignment/Structure.pptx new file mode 100644 index 0000000..a101f0c Binary files /dev/null and b/Notes_Assignment/Structure.pptx differ diff --git a/string/array_string.cpp b/string/array_string.cpp new file mode 100644 index 0000000..14cd252 --- /dev/null +++ b/string/array_string.cpp @@ -0,0 +1,17 @@ +#include +#include +using namespace std; +int main(){ + char name[5][30]={ + "rakesh", + "amitABCD","sumitRSTV", + "anujIKLH", + "UditPPPSSah" + + }; + + for(int i=0;i<5;i++) + cout< +using namespace std; +struct student{ + int roll; //10 + char name[30]; // anupam gulati + int marks[3]; // 90,78,56 + int total; + char grade; +}; + +int main(){ + student s[5]; + int i; + for(i=0;i<5;i++) + { + cout<<"\n Enter roll no :"; + cin>>s[i].roll; + cout<<"\n Enter name :"; + fflush(stdin); + cin.getline(s[i].name,30); + cout<<"\n Enter marks obtained in first subject (100) :"; + cin>>s[i].marks[0]; + + cout<<"\n Enter marks obtained in Second subject (100) :"; + cin>>s[i].marks[1]; + + cout<<"\n Enter marks obtained in Third Subject (100) :"; + cin>>s[i].marks[2]; + } + //processing area + for(i=0;i<5;i++) + { + + s[i].total = s[i].marks[0]+s[i].marks[1]+s[i].marks[2]; + + float per = s[i].total/3; + + if(per>=90) + s[i].grade = 'A'; + if(per<90 && per>=80) + s[i].grade='B'; + if(per<80) + s[i].grade ='C'; + } + +// // output phase + for(i=0;i<5;i++){ + + cout<<"\n Roll No :"< +#include +using namespace std; +struct student{ + int roll; + char name[30]; + char fname[30]; +}; + +void change_data(student &r){ + r.roll= 10; + strcpy(r.name,"rakesh"); + strcpy(r.fname,"sudarshan Sharma"); +} + +int main(){ + + student s={10,"Swapnil","R.K. Sharma"}; + + cout<<"\n Roll :"< +#include +using namespace std; +struct student{ + int roll; + char name[30]; + char fname[30]; +}; + +void change_data(student r){ + r.roll= 20; + strcpy(r.name,"rakesh"); + strcpy(r.fname,"sudarshan Sharma"); +} + +int main(){ + + student s={10,"Swapnil","R.K. Sharma"}; + + cout<<"\n Roll :"< +using namespace std; +int main(){ + int x; + cout< +#include +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}; + +int main() +{ + + student s; + // initialise structure variable + cin>>s.roll; + cin>>s.name; + cin>>s.fees; + cin>>s.grade; + + cout< +#include +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}; + +int main() +{ + student s={10,"saurabh sethi",2350.50,'B'}; + student r; + + //requirement - Initial R using S only + //method -1 + r.roll = s.roll; + strcpy(r.name , s.name); + r.fees = s.fees; + r.grade = s.grade; + + cout< +#include +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}; + +int main() +{ + student s={10,"saurabh sethi",2350.50,'B'}; + student r; + + //requirement - Initial R using S only + //method -1 + + r=s; + + cout<<"copied Roll :"< +#include +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}; + +int main() +{ + + student s; + // initialise structure variable + s.roll=10; + strcpy(s.name,"saurabh"); + s.fees = 1234.56; + s.grade='A'; + + cout< +using namespace std; +struct address{ + char houseNo[10]; + char society[20]; + char area[20]; + char locality[30]; + char city[20]; + char state[20]; + char country[100]; +}; + +struct date{ + int day; + int month; + int year; +}; +struct student{ + int roll; + char name[30]; + address add; + date dob; +}; +int main(){ + student s; + + return 0; +} diff --git a/structure/nested_structyre.cpp b/structure/nested_structyre.cpp new file mode 100644 index 0000000..fbb8430 --- /dev/null +++ b/structure/nested_structyre.cpp @@ -0,0 +1,28 @@ +#include +using namespace std; +struct address{ + char houseNo[10]; + char society[20]; + char area[20]; + char locality[30]; + char city[20]; + char state[20]; + char country[100]; +}; + +struct date{ + int day; + int month; + int year; +}; +struct student{ + int roll; + char name[30]; + address add; + date dob; +}; +int main(){ + student s; + + return 0; +} diff --git a/structure/nested_structyre.exe b/structure/nested_structyre.exe new file mode 100644 index 0000000..c8b8be7 Binary files /dev/null and b/structure/nested_structyre.exe differ diff --git a/structure/pass_structure-valid_method.cpp b/structure/pass_structure-valid_method.cpp new file mode 100644 index 0000000..0888e4e --- /dev/null +++ b/structure/pass_structure-valid_method.cpp @@ -0,0 +1,21 @@ +// structure as a function parameter + + +#include +using namespace std; +struct student{ + int roll; + char name[30]; + char fname[30]; +}; +void print_data(student r){ + cout<<"\n Roll :"< +using namespace std; +struct student{ + int roll; + char name[30]; + char fname[30]; + char address[100]; + char phone[15]; + char email[80]; + char website[100]; + int mark[3]; + int total; + char grade; + char std[10]; + char session[20]; + +}; +void print_data(int x, char y[],char add[],char ph[]){ + cout<<"\n Roll :"< +using namespace std; +struct student{ + int roll; //10 + char name[30]; // anupam gulati + int marks; // 90 + char grade; // A +}; +int main(){ + student s; + cout<<"\n Enter roll no :"; + cin>>s.roll; + cout<<"\n Enter name :"; + fflush(stdin); + cin.getline(s.name,30); + cout<<"\n Enter marks (100) :"; + cin>>s.marks; + cout<<"\n Enter grade :"; + cin>>s.grade; + + // output phase + + cout<<"\n Roll No :"< +using namespace std; +struct student{ + int roll; //10 + char name[30]; // anupam gulati + int marks[3]; // 90,78,56 + int total; + char grade; +}; + +int main(){ + student s; + + cout<<"\n Enter roll no :"; + cin>>s.roll; + cout<<"\n Enter name :"; + fflush(stdin); + cin.getline(s.name,30); + cout<<"\n Enter marks obtained in first subject (100) :"; + cin>>s.marks[0]; + + cout<<"\n Enter marks obtained in Second subject (100) :"; + cin>>s.marks[1]; + + cout<<"\n Enter marks obtained in Third Subject (100) :"; + cin>>s.marks[2]; + + //processing area + s.total = s.marks[0]+s.marks[1]+s.marks[2]; + + float per = s.total/3; + + if(per>=90) + s.grade = 'A'; + if(per<90 && per>=80) + s.grade='B'; + if(per<80) + s.grade ='C'; + + // output phase + + cout<<"\n Roll No :"< +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}; + +int main() +{ + + student s={10,"Saurabh",1234.56,'A',"12A"}; + cout< +#include +using namespace std; + struct student{ + int roll; + char name[30]; + float fees; + char grade; + char std[10]; +}s={10,"saurabh sethi",2350.50,'B'}; // initialization method-4 + +int main() +{ + + + cout<