├── Notes ├── readme.md ├── Unit_1_OOPs.pdf └── unit_2_OOPs.pdf └── Assisgnments ├── Submissions ├── 10_AI_ARNAV_JHA │ ├── File_pointer.cpp │ ├── Command_line_arg.cpp │ ├── Error_handle.cpp │ ├── Complex_No_Add.cpp │ ├── square_using_this.cpp │ ├── Time_add.cpp │ ├── extraction_insertion.cpp │ └── Calender.cpp ├── 71_Vidhirani_Netam │ ├── readme.md │ ├── assignment02.cpp │ ├── addhrminsec.cpp │ ├── add2complexno.cpp │ └── calender.cpp ├── 30_Karan_Singh_Rathore │ ├── readme.md │ ├── Assignment 2 │ ├── Time_add.cpp │ ├── Complex_addition.cpp │ └── Calendar.cpp ├── 58_shivangi │ └── readme.md ├── 31_Kavesh_Sahu │ └── readme.md ├── 42_Prabhat_kumar_singh_AI │ ├── solution │ ├── addhrminsec.cpp │ ├── add2complexno.cpp │ └── calender.cpp ├── 45_Rahul_Sahu │ ├── Readme.md │ ├── complex.cpp │ ├── time.cpp │ └── calendar.cpp ├── 17_Dipanshu_Gupta │ ├── readme.md │ ├── add_hour_min_sec.cpp │ ├── add_two_complex_no.cpp │ └── calendar_2024.cpp ├── 33_Kishlay_Kumar │ ├── readme.md │ ├── Assignment 2.cpp │ ├── addhrminsec.cpp │ ├── add2complexno.cpp │ └── calender.cpp ├── 59_Shivani_Kumari │ ├── Readme.md │ ├── complex.cpp │ ├── time_Add.cpp │ └── calendar.cpp ├── 68_Vasu_Dewangan │ ├── readme.md │ ├── complex_no.cpp │ ├── add_hrs_min_sec.cpp │ └── calender1.cpp ├── 67_tilak_Verma_#tasveer │ ├── readme.md │ ├── complex_no.cpp │ ├── add_hrs_min_sec.cpp │ └── calender1.cpp ├── Jai Keshav Sharma AI │ ├── Assignment_1 │ │ ├── adding_complex.cpp │ │ ├── time_adder.cpp │ │ └── year_calendar.cpp │ └── Assignment_2 │ │ └── this_pointer.cpp ├── 24_Hemant_Kumar_Singh_AI │ ├── readme.md │ ├── Assignment 2 │ ├── hrminsec.cpp │ ├── complexno.cpp │ └── calender.cpp ├── readme.md ├── 56_AI_Sharad_Singh_Thakur │ ├── readme.md │ ├── complex_add.cpp │ ├── add_time.cpp │ └── calender.cpp ├── Shobha_Ai_60 │ ├── this_operator.cpp │ ├── Complexnum.cpp │ ├── Hourmin.cpp │ └── Calander.cpp ├── Dhiraj_Kumar_AI_assignment 2 │ └── Assignment.cpp ├── 22_AI_Harsh_Sharma │ ├── this_operator.cpp.txt │ ├── Complex_No_Add.cpp │ ├── insertion_extraction.cpp │ ├── Time_add.cpp │ └── Calender.cpp ├── 25_AI_HRIDYESH_KUMAR │ ├── this_operator.cpp │ ├── solution_1.cpp │ ├── solution_2.cpp │ ├── insertion&extractionOperator.cpp │ └── solution_3.cpp ├── Abhay_singh_Ai │ ├── ComplexAdd.cpp │ ├── AddTime.cpp │ ├── Calander.cpp │ └── This_pointer.c ├── 39_AI_MOKSH │ ├── Complex_No_Add.cpp │ ├── Time_add.cpp │ └── Calender.cpp ├── Ketan_Dinkar_Ai │ ├── ComplexAdd.cpp │ ├── Time.cpp │ └── Calander.cpp ├── 02_Abhinav_Anand │ ├── Complex_No_Add.cpp │ ├── Time_add.cpp │ └── Calender.cpp ├── 03_AI_Abhinav_Shukla │ ├── Complex_No_Add.cpp │ ├── Time_add.cpp │ └── Calender.cpp ├── Sanjay_singh │ ├── Complexnum.cpp │ ├── Hourmin.cpp │ ├── Calander.cpp │ └── Assigment_2.c ├── 53_AI_SaurabhKumar │ ├── Assignment_2_solution.cpp │ ├── Solution_1.cpp │ └── Solution_2.cpp ├── Manaswi_Ai │ ├── addcomplexnumber.cpp │ ├── insertionandextraction.cpp │ ├── hoursecondminute.cpp │ └── calender.cpp ├── 38_AI_Mohnish_pradhan │ ├── solution_1.cpp │ └── solution_2.cpp ├── 11_AI__ARYAN_GUPTA │ ├── Solution2.cpp │ └── Solution3.cpp ├── 300012723057__CSE(AI)__SHIVAM CHOUDHARY │ ├── HourMinSecond.cpp │ ├── addcomplexnum.cpp │ └── calender2024.cpp ├── 66_tejas mishra │ ├── 2.txt │ ├── 1.txt │ └── 3.txt ├── 65_Suman_Kumar_AI │ ├── Solution_1.cpp │ └── Solution_2.cpp ├── 08_Anshul_Yadav │ ├── calender.cpp │ ├── add_complex.cpp │ └── time.cpp ├── 09_Anurag_Deshmukh │ ├── 2_time.cpp │ ├── 1_Complex_plus.cpp │ └── 3_calendar.cpp ├── 13_Bhooma_Anand │ ├── 2_time.cpp │ ├── 1_complex.cpp │ └── 3_calendar.cpp ├── 18_Durgesh_Kumar_Dewangan ├── 44_AI_PrernaSakre │ ├── sum_of_complex_number.cpp │ ├── to_add_time.cpp │ └── calender.cpp ├── Rupali │ ├── Adding 2 Time.cpp │ ├── Complex Sum.cpp │ ├── This Pointer.cpp │ └── Calender 2024.cpp ├── 47 AI Roshan Khatri │ └── Addcomplex.cpp ├── shaikhidayathulla_55 │ ├── ASS2.CPP │ └── ASS1.CPP ├── Alka │ ├── Adding Complex no.cpp │ ├── Time addition.cpp │ └── Calender.cpp ├── Kanchan_Patel_AI_29 │ ├── sum_complex.cpp │ ├── time_addition.cpp │ └── calender.cpp ├── Suleman_lakra_AI_64 │ ├── sum_complex.cpp │ ├── time_addition.cpp │ └── calender_.cpp ├── PARDHIV_35 │ ├── SOL_1.CPP │ └── SOL_2.CPP ├── 26_AI_Ishaan-Jha │ ├── sol_1.cpp │ └── sol_2.cpp ├── RAGHUWARNA_19 │ ├── COMPLEX_1.CPP │ └── TIME_2.CPP ├── Gagan_Hemang_12 │ ├── SOL_1.CPP │ └── SOL_2.CPP ├── Bhumika shriwas 14 │ ├── this_pointer.cpp │ ├── calender.cpp │ └── sumofcomplexnumber.cpp ├── 62_ShubhangiPandey │ ├── sumoftime.cpp │ ├── complexnumber.cpp │ └── calender.cpp ├── 06 AI AMAN BANJARE │ ├── Add_complexnum.cpp │ ├── AddTime.cpp │ └── Calender.cpp ├── 61_AI_ShreyanshPatel │ ├── Assignment_1_sol │ │ ├── Add_complexnum.cpp │ │ ├── Addtime.cpp │ │ └── Calender.cpp │ └── Assignment_3 ├── Bhumi │ ├── calender.cpp │ └── sumofcomplexnumber.cpp ├── 31 AI KAVESH SAHU │ ├── Add_complexnum.cpp │ ├── AddTime.cpp │ ├── Calender.cpp │ └── Assignment_2_solution ├── 37_AI_Mohan_Sahu │ ├── Add_complex_num..cpp │ ├── Add_Time.cpp │ └── Calender.cpp └── 57_AI_Shivam_Choudhary │ └── Assignment_2_solution ├── Assignment_6 └── Problem.md ├── Assignment2 └── Problem.md ├── Assignment_3 └── Problem1.md ├── Assignment_4 └── Problem.md ├── Assignment_1 ├── Problem_1.md ├── problem_2.md └── problem_3.md └── Assignment_5 └── Problem.md /Notes/readme.md: -------------------------------------------------------------------------------- 1 | # All the notes are present here. 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/10_AI_ARNAV_JHA/File_pointer.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/71_Vidhirani_Netam/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/30_Karan_Singh_Rathore/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/58_shivangi/readme.md: -------------------------------------------------------------------------------- 1 | # Shivangi 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/31_Kavesh_Sahu/readme.md: -------------------------------------------------------------------------------- 1 | # Kavesh Sahu 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/42_Prabhat_kumar_singh_AI/solution: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/45_Rahul_Sahu/Readme.md: -------------------------------------------------------------------------------- 1 | # Rahul Sahu 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/17_Dipanshu_Gupta/readme.md: -------------------------------------------------------------------------------- 1 | # Dipanshu Gupta 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/33_Kishlay_Kumar/readme.md: -------------------------------------------------------------------------------- 1 | # kishlay kumar 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/59_Shivani_Kumari/Readme.md: -------------------------------------------------------------------------------- 1 | # Shivani Kumari 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/68_Vasu_Dewangan/readme.md: -------------------------------------------------------------------------------- 1 | # Vasu Dewangan 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/67_tilak_Verma_#tasveer/readme.md: -------------------------------------------------------------------------------- 1 | # Tilak Verma 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Jai Keshav Sharma AI/Assignment_1/adding_complex.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Jai Keshav Sharma AI/Assignment_2/this_pointer.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Assisgnments/Assignment_6/Problem.md: -------------------------------------------------------------------------------- 1 | # Write a c++ for command line argument 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/24_Hemant_Kumar_Singh_AI/readme.md: -------------------------------------------------------------------------------- 1 | Hemant Kumar Singh 2 | -------------------------------------------------------------------------------- /Assisgnments/Assignment2/Problem.md: -------------------------------------------------------------------------------- 1 | # Write a program using 'this' pointer in c++. 2 | -------------------------------------------------------------------------------- /Assisgnments/Assignment_3/Problem1.md: -------------------------------------------------------------------------------- 1 | # Write a Program which shows the use of file pointer 2 | -------------------------------------------------------------------------------- /Notes/Unit_1_OOPs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HridyeshKumar/AI-OOPs-2nd-Sem/HEAD/Notes/Unit_1_OOPs.pdf -------------------------------------------------------------------------------- /Notes/unit_2_OOPs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HridyeshKumar/AI-OOPs-2nd-Sem/HEAD/Notes/unit_2_OOPs.pdf -------------------------------------------------------------------------------- /Assisgnments/Assignment_4/Problem.md: -------------------------------------------------------------------------------- 1 | # Write a c++ code for error handling in file input and output in function 2 | -------------------------------------------------------------------------------- /Assisgnments/Assignment_1/Problem_1.md: -------------------------------------------------------------------------------- 1 | # Problem Statement 2 | 3 | ## Write a c++ program to add two complex numbers. 4 | -------------------------------------------------------------------------------- /Assisgnments/Assignment_1/problem_2.md: -------------------------------------------------------------------------------- 1 | # Problem Statement 2 | 3 | ## Write a program to add hour,minute and second. 4 | -------------------------------------------------------------------------------- /Assisgnments/Assignment_1/problem_3.md: -------------------------------------------------------------------------------- 1 | # Problem Statement 2 | ## Write a c++ program to print the calendar of the year 2024 3 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/readme.md: -------------------------------------------------------------------------------- 1 | ## Create a folder of your name where you will be sunmitting your assignments throughout the semester. 2 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/56_AI_Sharad_Singh_Thakur/readme.md: -------------------------------------------------------------------------------- 1 | Name : Sharad Singh Thakur 2 | 3 | Sem : 2nd Sem 4 | 5 | Roll No : 300012723056 6 | 7 | Enroll : CC7453 8 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Shobha_Ai_60/this_operator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Test 4 | { 5 | private: 6 | int x; 7 | public: 8 | void setX (int x) 9 | { 10 | 11 | this->x = x; 12 | } 13 | void print() { 14 | cout << "x = " << x << endl; 15 | } 16 | }; 17 | 18 | int main() 19 | { 20 | Test obj; 21 | int x = 20; 22 | obj.setX(x); 23 | obj.print(); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Dhiraj_Kumar_AI_assignment 2/Assignment.cpp: -------------------------------------------------------------------------------- 1 | //Program to show function of this pointer 2 | #include 3 | using namespace std; 4 | class A{ 5 | int a,b; 6 | public: 7 | 8 | A(int a,int b){ 9 | this->a=a; 10 | this->b=b; 11 | } 12 | void show(){ 13 | cout<<"a="< 2 | class MyClass { 3 | private: 4 | int attribute; 5 | public: 6 | MyClass(int attribute) { 7 | this->attribute = attribute; 8 | } 9 | void printAttribute() { 10 | std::cout << "The attribute value is: " << this->attribute << std::endl; 11 | } 12 | }; 13 | int main() { 14 | MyClass obj(10); 15 | obj.printAttribute(); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/25_AI_HRIDYESH_KUMAR/this_operator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | class MyClass { 3 | private: 4 | int attribute; 5 | public: 6 | MyClass(int attribute) { 7 | // Use 'this' to refer to the member variable when parameter name is the same 8 | this->attribute = attribute; 9 | } 10 | void printAttribute() { 11 | std::cout << "The attribute value is: " << this->attribute << std::endl; 12 | } 13 | }; 14 | int main() { 15 | MyClass obj(10); 16 | obj.printAttribute(); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/10_AI_ARNAV_JHA/Command_line_arg.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main(int argc, char* argv[]) { 4 | // Check if any command line arguments are provided 5 | if (argc > 1) { 6 | // Print all the command line arguments 7 | cout << "Command line arguments:" << endl; 8 | for (int i = 1; i < argc; i++) { 9 | cout << argv[i] << endl; 10 | } 11 | } else { 12 | cout << "No command line arguments provided." << endl; 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/33_Kishlay_Kumar/Assignment 2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class asign{ 5 | private: 6 | int a; 7 | int b; 8 | public: 9 | void getdata(int a, int b){ 10 | this -> a = a; 11 | this -> b = b; 12 | } 13 | asign() { 14 | a = 10; 15 | b = 20; 16 | } 17 | void print() { 18 | cout<<"value of a = "< 2 | 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | Complex(double r = 0.0, double i = 0.0) : real(r), imaginary(i) {} 10 | 11 | Complex operator+(const Complex& other) const { 12 | return Complex(real + other.real, imaginary + other.imaginary); 13 | } 14 | 15 | void display() const { 16 | std::cout << real << " + " << imaginary << "i" << std::endl; 17 | } 18 | }; 19 | 20 | int main() { 21 | Complex num1(2.5, 3.7); 22 | Complex num2(1.8, 4.2); 23 | 24 | Complex sum = num1 + num2; 25 | 26 | std::cout << "Sum: "; 27 | sum.display(); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/30_Karan_Singh_Rathore/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct time{ 4 | int hr; 5 | int min; 6 | int sec; 7 | }; 8 | 9 | time addtime(time t1,time t2){ 10 | time sum; 11 | sum.sec=t1.sec+t2.sec; 12 | sum.min=t1.min+t2.min+sum.sec/60; 13 | sum.hr=t1.hr+t2.hr+sum.min/60; 14 | return sum; 15 | } 16 | 17 | int main(){ 18 | time t1,t2,sum; 19 | cout<<"Enter first time(in hr min sec):"; 20 | cin>>t1.hr>>t1.min>>t1.sec; 21 | cout<<"Enter second time(in hr min sec):"; 22 | cin>>t2.hr>>t2.min>>t2.sec; 23 | sum=addtime(t1,t2); 24 | cout<<"sum:"< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | class complex{ 4 | int a1,a2,b1,b2; 5 | public: 6 | complex(int a,int b, int c,int d){ 7 | a1=a; 8 | a2=c; 9 | b1=b; 10 | b2=d; 11 | } 12 | void display(){ 13 | cout<<"\nsum of complex numbers is : "<>a>>b; 20 | cout<<"\nenter second complex no real and imagenary part : "; 21 | cin>>c>>d; 22 | cout<<""< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | struct time{ 4 | int hr; 5 | int min; 6 | int sec; 7 | }; 8 | 9 | time addtime(time t1,time t2){ 10 | time sum; 11 | sum.sec=t1.sec+t2.sec; 12 | sum.min=t1.min+t2.min+sum.sec/60; 13 | sum.hr=t1.hr+t2.hr+sum.min/60; 14 | return sum; 15 | } 16 | 17 | int main(){ 18 | time t1,t2,sum; 19 | cout<<"Enter first time(in hr min sec):"; 20 | cin>>t1.hr>>t1.min>>t1.sec; 21 | cout<<"Enter second time(in hr min sec):"; 22 | cin>>t2.hr>>t2.min>>t2.sec; 23 | sum=addtime(t1,t2); 24 | cout<<"sum:"< 2 | using namespace std; 3 | struct time{ 4 | int hr; 5 | int min; 6 | int sec; 7 | }; 8 | 9 | time addtime(time t1,time t2){ 10 | time sum; 11 | sum.sec=t1.sec+t2.sec; 12 | sum.min=t1.min+t2.min+sum.sec/60; 13 | sum.hr=t1.hr+t2.hr+sum.min/60; 14 | return sum; 15 | } 16 | 17 | int main(){ 18 | time t1,t2,sum; 19 | cout<<"Enter first time(in hr min sec):"; 20 | cin>>t1.hr>>t1.min>>t1.sec; 21 | cout<<"Enter second time(in hr min sec):"; 22 | cin>>t2.hr>>t2.min>>t2.sec; 23 | sum=addtime(t1,t2); 24 | cout<<"sum:"< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex Number 1 is :"< 2 | using namespace std; 3 | struct time{ 4 | int hr; 5 | int min; 6 | int sec; 7 | }; 8 | 9 | time addtime(time t1,time t2){ 10 | time sum; 11 | sum.sec=t1.sec+t2.sec; 12 | sum.min=t1.min+t2.min+sum.sec/60; 13 | sum.hr=t1.hr+t2.hr+sum.min/60; 14 | return sum; 15 | } 16 | 17 | int main(){ 18 | time t1,t2,sum; 19 | cout<<"Enter first time(in hr min sec):"; 20 | cin>>t1.hr>>t1.min>>t1.sec; 21 | cout<<"Enter second time(in hr min sec):"; 22 | cin>>t2.hr>>t2.min>>t2.sec; 23 | sum=addtime(t1,t2); 24 | cout<<"sum:"< 2 | using namespace std; 3 | struct time{ 4 | int hr; 5 | int min; 6 | int sec; 7 | }; 8 | 9 | time addtime(time t1,time t2){ 10 | time sum; 11 | sum.sec=t1.sec+t2.sec; 12 | sum.min=t1.min+t2.min+sum.sec/60; 13 | sum.hr=t1.hr+t2.hr+sum.min/60; 14 | return sum; 15 | } 16 | 17 | int main(){ 18 | time t1,t2,sum; 19 | cout<<"Enter first time(in hr min sec):"; 20 | cin>>t1.hr>>t1.min>>t1.sec; 21 | cout<<"Enter second time(in hr min sec):"; 22 | cin>>t2.hr>>t2.min>>t2.sec; 23 | sum=addtime(t1,t2); 24 | cout<<"sum:"< 2 | 3 | using namespace std; 4 | 5 | class Complex { 6 | private: 7 | float real; 8 | float imaginary; 9 | public: 10 | Complex(float r, float i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | Complex add(Complex c) { 16 | float realSum = real + c.real; 17 | float imaginarySum = imaginary + c.imaginary; 18 | return Complex(realSum, imaginarySum); 19 | } 20 | 21 | void display() { 22 | cout << "Sum = " << real << " + " << imaginary << "i" << endl; 23 | } 24 | }; 25 | 26 | int main() { 27 | Complex num1(3, 4); 28 | Complex num2(1, 2); 29 | Complex sum = num1.add(num2); 30 | sum.display(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Shobha_Ai_60/Complexnum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Complex { 6 | private: 7 | float real; 8 | float imaginary; 9 | public: 10 | Complex(float r, float i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | Complex add(Complex c) { 16 | float realSum = real + c.real; 17 | float imaginarySum = imaginary + c.imaginary; 18 | return Complex(realSum, imaginarySum); 19 | } 20 | 21 | void display() { 22 | cout << "Sum = " << real << " + " << imaginary << "i" << endl; 23 | } 24 | }; 25 | 26 | int main() { 27 | Complex num1(3, 4); 28 | Complex num2(1, 2); 29 | Complex sum = num1.add(num2); 30 | sum.display(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/30_Karan_Singh_Rathore/Complex_addition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct complex{ 4 | float real; 5 | //imag=imaginary 6 | float imag; 7 | }; 8 | 9 | complex addcomplex(complex num1,complex num2){ 10 | complex sum; 11 | sum.real=num1.real+num2.real; 12 | sum.imag=num1.imag+num2.imag; 13 | return sum; 14 | } 15 | 16 | int main(){ 17 | complex num1,num2,sum; 18 | cout<<"Enter the real and imaginary parts of first compleax number: "; 19 | cin>>num1.real>>num1.imag; 20 | 21 | cout<<"Enter the real and imaginary parts of second compleax number: "; 22 | cin>>num2.real>>num2.imag; 23 | 24 | sum=addcomplex(num1,num2); 25 | cout<<"sum: "< 2 | 3 | using namespace std; 4 | 5 | class Complex { 6 | private: 7 | float real; 8 | float imaginary; 9 | public: 10 | Complex(float r, float i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | Complex add(Complex c) { 16 | float realSum = real + c.real; 17 | float imaginarySum = imaginary + c.imaginary; 18 | return Complex(realSum, imaginarySum); 19 | } 20 | 21 | void display() { 22 | cout << "Sum = " << real << " + " << imaginary << "i" << endl; 23 | } 24 | }; 25 | 26 | int main() { 27 | Complex num1(3, 4); 28 | Complex num2(1, 2); 29 | Complex sum = num1.add(num2); 30 | sum.display(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/53_AI_SaurabhKumar/Assignment_2_solution.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Employee { 4 | public: 5 | int id; 6 | string name; 7 | float salary; 8 | Employee(int id, string name, float salary) 9 | { 10 | this->id = id; 11 | this->name = name; 12 | this->salary = salary; 13 | } 14 | void display() 15 | { 16 | cout< 2 | using namespace std; 3 | class complex{ 4 | public: 5 | float r,i; 6 | complex(float tr=0,float ti=0) 7 | { 8 | r=tr; 9 | i=ti; 10 | } 11 | complex add(complex c1,complex c2) 12 | { 13 | complex tp; 14 | tp.r=c1.r+c2.r; 15 | tp.i=c1.i+c2.i; 16 | return tp; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | complex c1(5,6); 23 | cout<<"Complex No. 1 is :"< 2 | using namespace std; 3 | struct complex{ 4 | float real; 5 | //imag=imaginary 6 | float imag; 7 | }; 8 | 9 | complex addcomplex(complex num1,complex num2){ 10 | complex sum; 11 | sum.real=num1.real+num2.real; 12 | sum.imag=num1.imag+num2.imag; 13 | return sum; 14 | } 15 | 16 | int main(){ 17 | complex num1,num2,sum; 18 | cout<<"Enter the real and imaginary parts of first compleax number: "; 19 | cin>>num1.real>>num1.imag; 20 | 21 | cout<<"Enter the real and imaginary parts of second compleax number: "; 22 | cin>>num2.real>>num2.imag; 23 | 24 | sum=addcomplex(num1,num2); 25 | cout<<"sum: "< 2 | using namespace std; 3 | struct complex{ 4 | float real; 5 | //imag=imaginary 6 | float imag; 7 | }; 8 | 9 | complex addcomplex(complex num1,complex num2){ 10 | complex sum; 11 | sum.real=num1.real+num2.real; 12 | sum.imag=num1.imag+num2.imag; 13 | return sum; 14 | } 15 | 16 | int main(){ 17 | complex num1,num2,sum; 18 | cout<<"Enter the real and imaginary parts of first compleax number: "; 19 | cin>>num1.real>>num1.imag; 20 | 21 | cout<<"Enter the real and imaginary parts of second compleax number: "; 22 | cin>>num2.real>>num2.imag; 23 | 24 | sum=addcomplex(num1,num2); 25 | cout<<"sum: "< 2 | using namespace std; 3 | struct complex{ 4 | float real; 5 | //imag=imaginary 6 | float imag; 7 | }; 8 | 9 | complex addcomplex(complex num1,complex num2){ 10 | complex sum; 11 | sum.real=num1.real+num2.real; 12 | sum.imag=num1.imag+num2.imag; 13 | return sum; 14 | } 15 | 16 | int main(){ 17 | complex num1,num2,sum; 18 | cout<<"Enter the real and imaginary parts of first compleax number: "; 19 | cin>>num1.real>>num1.imag; 20 | 21 | cout<<"Enter the real and imaginary parts of second compleax number: "; 22 | cin>>num2.real>>num2.imag; 23 | 24 | sum=addcomplex(num1,num2); 25 | cout<<"sum: "< 2 | using namespace std; 3 | struct complex{ 4 | float real; 5 | //imag=imaginary 6 | float imag; 7 | }; 8 | 9 | complex addcomplex(complex num1,complex num2){ 10 | complex sum; 11 | sum.real=num1.real+num2.real; 12 | sum.imag=num1.imag+num2.imag; 13 | return sum; 14 | } 15 | 16 | int main(){ 17 | complex num1,num2,sum; 18 | cout<<"Enter the real and imaginary parts of first compleax number: "; 19 | cin>>num1.real>>num1.imag; 20 | 21 | cout<<"Enter the real and imaginary parts of second compleax number: "; 22 | cin>>num2.real>>num2.imag; 23 | 24 | sum=addcomplex(num1,num2); 25 | cout<<"sum: "< 2 | using namespace std; 3 | class complex{ 4 | private : 5 | int a; 6 | int b; 7 | public : 8 | void setdata(int v1 , int v2){ 9 | a = v1; 10 | b = v2; 11 | } 12 | void sum(complex o1 , complex o2){ 13 | a = o1.a + o2.a; 14 | b = o1.b + o2.b; 15 | } 16 | void print(){ 17 | cout<<" your complex number is "< 2 | using namespace std; 3 | 4 | class Demo 5 | { 6 | private: 7 | int x; 8 | public: 9 | void squarex (int x) 10 | { 11 | // The 'this' pointer is used to retrieve the object's x 12 | // hidden by the local variable 'x' 13 | this->x = x*x; 14 | } 15 | void print() { cout << "x = " << x << endl; } 16 | }; 17 | 18 | int main() 19 | { 20 | Demo obj; 21 | int x = 20; 22 | obj.squarex(x); 23 | obj.print(); 24 | return 0; 25 | } 26 | 27 | //The this pointer in C++ holds the memory address of the class instance (i.e., object) that is 28 | //being called from the member function, allowing those functions to access the correct data members of that specific object. 29 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/38_AI_Mohnish_pradhan/solution_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | class Complex { 6 | private: 7 | float real; 8 | float imag; 9 | 10 | public: 11 | 12 | Complex(float r = 0.0, float i = 0.0) : real(r), imag(i) {} 13 | 14 | Complex operator+(const Complex& other) { 15 | return Complex(real + other.real, imag + other.imag); 16 | } 17 | void display() const { 18 | cout << real << " + " << imag << "i" << endl; 19 | } 20 | }; 21 | 22 | int main() { 23 | 24 | Complex c1(3.5, 2.5); 25 | Complex c2(1.5, 4.5); 26 | Complex c3 = c1 + c2; 27 | cout << "The sum of "; 28 | c1.display(); 29 | cout << "and "; 30 | c2.display(); 31 | cout << "is "; 32 | c3.display(); 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/11_AI__ARYAN_GUPTA/Solution2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Example 5 | { 6 | int a; 7 | int x; 8 | 9 | public: 10 | void setData(int a) 11 | { 12 | this->a = a; 13 | } 14 | 15 | Example &setdata2(int x) 16 | { 17 | this->x = x; 18 | return *this; 19 | } 20 | 21 | void display() 22 | { 23 | cout << "The value of a is:" << a << endl; 24 | } 25 | void display2() 26 | { 27 | cout << "The value of x is:" << x << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | Example a; 34 | a.setData(10); 35 | a.display(); 36 | 37 | Example x; 38 | x.setdata2(5).display2(); 39 | 40 | return 0; 41 | } 42 | 43 | // "this" keyword is a pointer which points to the object which invokes the member function. 44 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/300012723057__CSE(AI)__SHIVAM CHOUDHARY/HourMinSecond.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time 4 | { 5 | private: 6 | int hour,minute,second; 7 | public: 8 | Time() 9 | { 10 | hour=minute=second=0; 11 | } 12 | void input() 13 | { 14 | cout <<"Enter hour:"<< endl; 15 | cin>>hour; 16 | cout<<"Enter minute:"<>minute; 18 | cout<<"Enter second:"<>second; 20 | } 21 | void display() 22 | { 23 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int hour1,minute1,second1; 7 | 8 | int hour2,minute2,second2; 9 | 10 | int hour,minute,second; 11 | 12 | 13 | cout<<"***Enter first time***"<>hour1; 15 | cout<<"Minutes: "; cin>>minute1; 16 | cout<<"Seconds: "; cin>>second1; 17 | 18 | 19 | cout<<"***Enter second time***"<>hour2; 21 | cout<<"Minutes: "; cin>>minute2; 22 | cout<<"Seconds: "; cin>>second2; 23 | 24 | 25 | second=second1+second2; 26 | minute=minute1+minute2+(second/60); 27 | hour=hour1+hour2+(minute/60); 28 | minute=minute%60; 29 | second=second%60; 30 | 31 | 32 | cout<<"Total Time is: "< 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | int real, imag; 8 | public: 9 | Complex(int r = 0, int i =0) 10 | { real = r; imag = i; } 11 | friend ostream & operator << (ostream &out, const Complex &c); 12 | friend istream & operator >> (istream &in, Complex &c); 13 | }; 14 | 15 | ostream & operator << (ostream &out, const Complex &c) 16 | { 17 | out << c.real; 18 | out << "+i" << c.imag << endl; 19 | return out; 20 | } 21 | 22 | istream & operator >> (istream &in, Complex &c) 23 | { 24 | cout << "Enter Real Part "; 25 | in >> c.real; 26 | cout << "Enter Imaginary Part "; 27 | in >> c.imag; 28 | return in; 29 | } 30 | 31 | int main() 32 | { 33 | Complex c1; 34 | cin >> c1; 35 | cout << "The complex object is "; 36 | cout << c1; 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Abhay_singh_Ai/AddTime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Time { 4 | int hours; 5 | int minutes; 6 | int seconds; 7 | }; 8 | 9 | Time addTime(const Time& t1, const Time& t2) { 10 | Time result; 11 | int totalSeconds = t1.seconds + t2.seconds; 12 | result.seconds = totalSeconds % 60; 13 | int carrySeconds = totalSeconds / 60; 14 | 15 | int totalMinutes = t1.minutes + t2.minutes + carrySeconds; 16 | result.minutes = totalMinutes % 60; 17 | int carryMinutes = totalMinutes / 60; 18 | 19 | result.hours = t1.hours + t2.hours + carryMinutes; 20 | 21 | return result; 22 | } 23 | 24 | int main() { 25 | Time time1 = {10, 30, 45}; 26 | Time time2 = {2, 15, 20}; 27 | 28 | Time sum = addTime(time1, time2); 29 | 30 | std::cout << "Sum of times: " << sum.hours << " hours, " << sum.minutes << " minutes, " << sum.seconds << " seconds" << std::endl; 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/53_AI_SaurabhKumar/Solution_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex { 5 | int real; 6 | int imaginary; 7 | 8 | public: 9 | 10 | void addComp(Complex c1, Complex c2) { 11 | real = c1.real + c2.real; 12 | imaginary = c1.imaginary + c2.imaginary; 13 | } 14 | 15 | void setData() { 16 | int a, b; 17 | cout << "Enter real and imaginary part respectively: "; 18 | cin >> a >> b; 19 | real = a; 20 | imaginary = b; 21 | } 22 | void getData() { 23 | cout << real << " + " << imaginary << "i" << endl; 24 | } 25 | }; 26 | 27 | int main() { 28 | 29 | Complex c1, c2, c3; 30 | c1.setData(); 31 | cout << "c1 : "; 32 | c1.getData(); 33 | c2.setData(); 34 | cout << "c2 : "; 35 | c2.getData(); 36 | 37 | c3.addComp(c1, c2); 38 | 39 | cout << "Sum of c1 and c2 : "; 40 | c3.getData(); 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/65_Suman_Kumar_AI/Solution_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex { 5 | int real; 6 | int imaginary; 7 | 8 | public: 9 | 10 | void addComp(Complex c1, Complex c2) { 11 | real = c1.real + c2.real; 12 | imaginary = c1.imaginary + c2.imaginary; 13 | } 14 | 15 | void setData() { 16 | int a, b; 17 | cout << "Enter real and imaginary part respectively: "; 18 | cin >> a >> b; 19 | real = a; 20 | imaginary = b; 21 | } 22 | void getData() { 23 | cout << real << " + " << imaginary << "i" << endl; 24 | } 25 | }; 26 | 27 | int main() { 28 | 29 | Complex c1, c2, c3; 30 | c1.setData(); 31 | cout << "c1 : "; 32 | c1.getData(); 33 | c2.setData(); 34 | cout << "c2 : "; 35 | c2.getData(); 36 | 37 | c3.addComp(c1, c2); 38 | 39 | cout << "Sum of c1 and c2 : "; 40 | c3.getData(); 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Jai Keshav Sharma AI/Assignment_1/time_adder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class time 5 | { 6 | int hour; 7 | int min; 8 | int second; 9 | 10 | public: 11 | void setdata(int, int, int); 12 | void addTimes(time &, time &); 13 | void dispSum(); 14 | }t1, t2, t3; 15 | 16 | void time ::setdata(int h, int m, int s) 17 | { 18 | hour = h; 19 | min = m; 20 | second = s; 21 | } 22 | void time ::addTimes(time &o1, time &o2) 23 | { 24 | hour = o1.hour + o2.hour; 25 | min = o1.min + o2.min; 26 | second = o1.second + o2.second; 27 | } 28 | void time ::dispSum() 29 | { 30 | cout << "sum is: " << hour << " hours, " << min << " mins, " << second << " seconds" << endl; 31 | } 32 | int main() 33 | { 34 | 35 | 36 | t1.setdata(7, 8, 9); 37 | t2.setdata(10, 11, 12); 38 | 39 | t3.addTimes(t1, t2); 40 | 41 | t3.dispSum(); 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/53_AI_SaurabhKumar/Solution_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time { 5 | int hrs; 6 | int min; 7 | int sec; 8 | 9 | public: 10 | void setData() { 11 | int a, b ,c; 12 | cout << "Enter hour , minute and second respectively - "; 13 | cin >> a >> b >> c; 14 | hrs= a; 15 | min = b; 16 | sec = c; 17 | } 18 | void getData() { 19 | cout << hrs << ":" << min << ":" << sec << endl; 20 | } 21 | void timeSum(Time t1, Time t2) { 22 | hrs = t1.hrs + t2.hrs; 23 | min = t1.min + t2.min; 24 | sec = t1.sec + t2.sec; 25 | } 26 | }; 27 | 28 | int main () { 29 | 30 | Time t1 , t2, t3; 31 | t1.setData(); 32 | cout << "t1 : "; 33 | t1.getData(); 34 | t2.setData(); 35 | cout << "t2 : "; 36 | t2.getData(); 37 | t3.timeSum(t1, t2); 38 | cout << "Sum of t1 and t2 is : "; 39 | t3.getData(); 40 | 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/65_Suman_Kumar_AI/Solution_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time { 5 | int hrs; 6 | int min; 7 | int sec; 8 | 9 | public: 10 | void setData() { 11 | int a, b ,c; 12 | cout << "Enter hour , minute and second respectively - "; 13 | cin >> a >> b >> c; 14 | hrs= a; 15 | min = b; 16 | sec = c; 17 | } 18 | void getData() { 19 | cout << hrs << ":" << min << ":" << sec << endl; 20 | } 21 | void timeSum(Time t1, Time t2) { 22 | hrs = t1.hrs + t2.hrs; 23 | min = t1.min + t2.min; 24 | sec = t1.sec + t2.sec; 25 | } 26 | }; 27 | 28 | int main () { 29 | 30 | Time t1 , t2, t3; 31 | t1.setData(); 32 | cout << "t1 : "; 33 | t1.getData(); 34 | t2.setData(); 35 | cout << "t2 : "; 36 | t2.getData(); 37 | t3.timeSum(t1, t2); 38 | cout << "Sum of t1 and t2 is : "; 39 | t3.getData(); 40 | 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/56_AI_Sharad_Singh_Thakur/complex_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex{ 5 | private: 6 | double real; 7 | double imag; 8 | public: 9 | Complex(double real,double imag){ 10 | this->real = real; 11 | this->imag = imag; 12 | } 13 | Complex add(Complex first,Complex second){ 14 | return Complex(first.real + second.real ,first.imag + second.imag ); 15 | } 16 | void Print(){ 17 | cout << this->real << '+' << this->imag << "i"< 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int year = 2024; 8 | int month = 1; // January 9 | int daysInMonth = 31; 10 | int startingDay = 3; // Wednesday (0 for Sunday, 1 for Monday, ..., 6 for Saturday) 11 | 12 | // Print the month and year 13 | cout << " January " << year << endl; 14 | cout << " Su Mo Tu We Th Fr Sa" << endl; 15 | 16 | // Print leading spaces for the first week 17 | for (int i = 0; i < startingDay; ++i) { 18 | cout << " "; 19 | } 20 | 21 | // Print the days of the month 22 | for (int day = 1; day <= daysInMonth; ++day) { 23 | // Print the day 24 | cout << setw(2) << day << " "; 25 | 26 | // If it's Saturday, start a new line 27 | if ((day + startingDay) % 7 == 0) { 28 | cout << endl; 29 | } 30 | } 31 | 32 | cout << endl; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/09_Anurag_Deshmukh/2_time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int year = 2024; 8 | int month = 1; // January 9 | int daysInMonth = 31; 10 | int startingDay = 3; // Wednesday (0 for Sunday, 1 for Monday, ..., 6 for Saturday) 11 | 12 | // Print the month and year 13 | cout << " January " << year << endl; 14 | cout << " Su Mo Tu We Th Fr Sa" << endl; 15 | 16 | // Print leading spaces for the first week 17 | for (int i = 0; i < startingDay; ++i) { 18 | cout << " "; 19 | } 20 | 21 | // Print the days of the month 22 | for (int day = 1; day <= daysInMonth; ++day) { 23 | // Print the day 24 | cout << setw(2) << day << " "; 25 | 26 | // If it's Saturday, start a new line 27 | if ((day + startingDay) % 7 == 0) { 28 | cout << endl; 29 | } 30 | } 31 | 32 | cout << endl; 33 | 34 | return 0; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/13_Bhooma_Anand/2_time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int hours1, minutes1, seconds1; 7 | int hours2, minutes2, seconds2; 8 | 9 | cout << "Enter first time (hours minutes seconds): "; 10 | cin >> hours1 >> minutes1 >> seconds1; 11 | 12 | cout << "Enter second time (hours minutes seconds): "; 13 | cin >> hours2 >> minutes2 >> seconds2; 14 | 15 | int total_hours = hours1 + hours2; 16 | int total_minutes = minutes1 + minutes2; 17 | int total_seconds = seconds1 + seconds2; 18 | 19 | if (total_seconds >= 60) { 20 | total_minutes += total_seconds / 60; 21 | total_seconds %= 60; 22 | } 23 | 24 | if (total_minutes >= 60) { 25 | total_hours += total_minutes / 60; 26 | total_minutes %= 60; 27 | } 28 | 29 | cout << "Total time: " << total_hours << " hours, " << total_minutes << " minutes, " << total_seconds << " seconds." << endl; 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/18_Durgesh_Kumar_Dewangan: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | std::vector months = { 7 | "January", "February", "March", "April", "May", "June", 8 | "July", "August", "September", "October", "November", "December" 9 | }; 10 | std::vector days = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 11 | std::vector dayOfWeek = { 1, 4, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6 }; 12 | for (int m = 0; m < 12; ++m) { 13 | std::cout << "\n\n " << months[m] << " 2024\n"; 14 | std::cout << " Su Mo Tu We Th Fr Sa\n"; 15 | for (int s = 0; s < dayOfWeek[m]; ++s) { 16 | std::cout << " "; 17 | } 18 | for (int d = 1; d <= days[m]; ++d) { 19 | std::cout << std::setw(4) << d; 20 | if ((dayOfWeek[m] + d) % 7 == 0) { 21 | std::cout << "\n"; 22 | } 23 | } 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/44_AI_PrernaSakre/sum_of_complex_number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class complex 4 | { 5 | int a; 6 | int b; 7 | 8 | public: 9 | void get() 10 | { 11 | cout << "enter real part:" << endl; 12 | cin >> a; 13 | cout << "enter imaginary part:" << endl; 14 | cin >> b; 15 | } 16 | void setdatabysum(complex o1, complex o2) 17 | { 18 | a = o1.a + o2.a; 19 | b = o1.b + o2.b; 20 | } 21 | void printnumber() 22 | { 23 | cout << a << "+" << b << "i" << endl; 24 | } 25 | }; 26 | int main() 27 | { 28 | complex x1, x2, x3; 29 | x1.get(); 30 | cout << "first complex number is:"; 31 | x1.printnumber(); 32 | 33 | x2.get(); 34 | cout << "second complex number is:"; 35 | x2.printnumber(); 36 | 37 | x3.setdatabysum(x1, x2); 38 | cout << "after addintion , Complex number is:"; 39 | x3.printnumber(); 40 | 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Rupali/Adding 2 Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | //for first time 7 | int hour1,minute1,second1; 8 | //for second time 9 | int hour2,minute2,second2; 10 | //for the total(sum) time 11 | int hour,minute,second; 12 | 13 | //taking the input from user 14 | cout<<"***Enter first time***"<>hour1; 16 | cout<<"Minutes: "; cin>>minute1; 17 | cout<<"Seconds: "; cin>>second1; 18 | 19 | //taking the input from user 20 | cout<<"***Enter second time***"<>hour2; 22 | cout<<"Minutes: "; cin>>minute2; 23 | cout<<"Seconds: "; cin>>second2; 24 | 25 | //adding the entered times 26 | second=second1+second2; 27 | minute=minute1+minute2+(second/60); 28 | hour=hour1+hour2+(minute/60); 29 | minute=minute%60; 30 | second=second%60; 31 | 32 | //displaying total time 33 | cout<<"Total Time is: "< 2 | using namespace std; 3 | 4 | // Define a class to represent a complex number 5 | class Complex { 6 | public: 7 | // real and imaginary parts 8 | double real, imag; 9 | 10 | // Default constructor 11 | Complex(double r = 0.0, double i = 0.0) : real(r), imag(i) {} 12 | 13 | // Function to add two Complex numbers 14 | Complex operator + (Complex const &obj) { 15 | Complex res; 16 | res.real = real + obj.real; 17 | res.imag = imag + obj.imag; 18 | return res; 19 | } 20 | 21 | // Function to print a Complex number 22 | void print() { 23 | cout << real << " + i" << imag << endl; 24 | } 25 | }; 26 | 27 | int main() { 28 | // Create two complex numbers 29 | Complex c1(10, 5), c2(2, 4); 30 | 31 | // Add the numbers 32 | Complex c3 = c1 + c2; 33 | 34 | // Print the result 35 | cout << "Result is: "; 36 | c3.print(); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/shaikhidayathulla_55/ASS2.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | //for first time 7 | int hour1,minute1,second1; 8 | //for second time 9 | int hour2,minute2,second2; 10 | //for the total(sum) time 11 | int hour,minute,second; 12 | 13 | //taking the input from user 14 | cout<<"***Enter first time***"<>hour1; 16 | cout<<"Minutes: "; cin>>minute1; 17 | cout<<"Seconds: "; cin>>second1; 18 | 19 | //taking the input from user 20 | cout<<"***Enter second time***"<>hour2; 22 | cout<<"Minutes: "; cin>>minute2; 23 | cout<<"Seconds: "; cin>>second2; 24 | 25 | //adding the entered times 26 | second=second1+second2; 27 | minute=minute1+minute2+(second/60); 28 | hour=hour1+hour2+(minute/60); 29 | minute=minute%60; 30 | second=second%60; 31 | 32 | //displaying total time 33 | cout<<"Total Time is: "< 2 | 3 | using namespace std; 4 | 5 | // Define a structure for complex numbers 6 | struct Complex { 7 | float real; 8 | float imag; 9 | }; 10 | 11 | // Function to add two complex numbers 12 | Complex addComplex(Complex num1, Complex num2) { 13 | Complex sum; 14 | sum.real = num1.real + num2.real; 15 | sum.imag = num1.imag + num2.imag; 16 | return sum; 17 | } 18 | 19 | int main() { 20 | Complex num1, num2, sum; 21 | 22 | // Input for first complex number 23 | cout << "Enter real and imaginary parts of first complex number:" << endl; 24 | cin >> num1.real >> num1.imag; 25 | 26 | // Input for second complex number 27 | cout << "Enter real and imaginary parts of second complex number:" << endl; 28 | cin >> num2.real >> num2.imag; 29 | 30 | // Add the complex numbers 31 | sum = addComplex(num1, num2); 32 | 33 | // Display the result 34 | cout << "Sum = " << sum.real << " + " << sum.imag << "i" << endl; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/08_Anshul_Yadav/add_complex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Define a structure for complex numbers 6 | struct Complex { 7 | float real; 8 | float imag; 9 | }; 10 | 11 | // Function to add two complex numbers 12 | Complex addComplex(Complex num1, Complex num2) { 13 | Complex sum; 14 | sum.real = num1.real + num2.real; 15 | sum.imag = num1.imag + num2.imag; 16 | return sum; 17 | } 18 | 19 | int main() { 20 | Complex num1, num2, sum; 21 | 22 | // Input for first complex number 23 | cout << "Enter real and imaginary parts of first complex number:" << endl; 24 | cin >> num1.real >> num1.imag; 25 | 26 | // Input for second complex number 27 | cout << "Enter real and imaginary parts of second complex number:" << endl; 28 | cin >> num2.real >> num2.imag; 29 | 30 | // Add the complex numbers 31 | sum = addComplex(num1, num2); 32 | 33 | // Display the result 34 | cout << "Sum = " << sum.real << " + " << sum.imag << "i" << endl; 35 | 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/09_Anurag_Deshmukh/1_Complex_plus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Define a structure for complex numbers 6 | struct Complex { 7 | float real; 8 | float imag; 9 | }; 10 | 11 | // Function to add two complex numbers 12 | Complex addComplex(Complex num1, Complex num2) { 13 | Complex sum; 14 | sum.real = num1.real + num2.real; 15 | sum.imag = num1.imag + num2.imag; 16 | return sum; 17 | } 18 | 19 | int main() { 20 | Complex num1, num2, sum; 21 | 22 | // Input for first complex number 23 | cout << "Enter real and imaginary parts of first complex number:" << endl; 24 | cin >> num1.real >> num1.imag; 25 | 26 | // Input for second complex number 27 | cout << "Enter real and imaginary parts of second complex number:" << endl; 28 | cin >> num2.real >> num2.imag; 29 | 30 | // Add the complex numbers 31 | sum = addComplex(num1, num2); 32 | 33 | // Display the result 34 | cout << "Sum = " << sum.real << " + " << sum.imag << "i" << endl; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Alka/Adding Complex no.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | // Constructor to initialize the complex number 10 | Complex(double r, double i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | // Function to add two complex numbers 16 | Complex add(const Complex& other) { 17 | double newReal = real + other.real; 18 | double newImaginary = imaginary + other.imaginary; 19 | return Complex(newReal, newImaginary); 20 | } 21 | 22 | // Function to display the complex number 23 | void display() { 24 | std::cout << real << " + " << imaginary << "i" << std::endl; 25 | } 26 | }; 27 | 28 | int main() { 29 | // Creating two complex numbers 30 | Complex num1(3.5, 2.5); 31 | Complex num2(1.2, 4.8); 32 | 33 | // Adding two complex numbers 34 | Complex sum = num1.add(num2); 35 | 36 | // Displaying the result 37 | std::cout << "Sum: "; 38 | sum.display(); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Kanchan_Patel_AI_29/sum_complex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Structure to represent a complex number 6 | struct Complex { 7 | float real; 8 | float imag; 9 | }; 10 | 11 | // Function to add two complex numbers 12 | Complex addComplex(Complex num1, Complex num2) { 13 | Complex result; 14 | result.real = num1.real + num2.real; 15 | result.imag = num1.imag + num2.imag; 16 | return result; 17 | } 18 | 19 | int main() { 20 | Complex num1, num2, sum; 21 | 22 | // Input first complex number 23 | cout << "Enter real and imaginary parts of first complex number: "; 24 | cin >> num1.real >> num1.imag; 25 | 26 | // Input second complex number 27 | cout << "Enter real and imaginary parts of second complex number: "; 28 | cin >> num2.real >> num2.imag; 29 | 30 | // Add two complex numbers 31 | sum = addComplex(num1, num2); 32 | 33 | // Display the result 34 | cout << "Sum = " << sum.real << " + " << sum.imag << "i"; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Rupali/Complex Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Class to represent complex numbers 6 | class Complex { 7 | private: 8 | float real; 9 | float imag; 10 | 11 | public: 12 | // Constructor to initialize the complex number 13 | Complex(float r, float i) : real(r), imag(i) {} 14 | 15 | // Function to add two complex numbers 16 | Complex add(const Complex& other) const { 17 | float real_sum = real + other.real; 18 | float imag_sum = imag + other.imag; 19 | return Complex(real_sum, imag_sum); 20 | } 21 | 22 | // Function to display the complex number 23 | void display() const { 24 | cout << real << " + " << imag << "i"; 25 | } 26 | }; 27 | 28 | int main() { 29 | // Create two complex numbers 30 | Complex num1(3.5, 2.7); 31 | Complex num2(1.2, 4.3); 32 | 33 | // Add the complex numbers 34 | Complex sum = num1.add(num2); 35 | 36 | // Display the result 37 | cout << "Sum: "; 38 | sum.display(); 39 | cout << endl; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Suleman_lakra_AI_64/sum_complex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Structure to represent a complex number 6 | struct Complex { 7 | float real; 8 | float imag; 9 | }; 10 | 11 | // Function to add two complex numbers 12 | Complex addComplex(Complex num1, Complex num2) { 13 | Complex result; 14 | result.real = num1.real + num2.real; 15 | result.imag = num1.imag + num2.imag; 16 | return result; 17 | } 18 | 19 | int main() { 20 | Complex num1, num2, sum; 21 | 22 | // Input first complex number 23 | cout << "Enter real and imaginary parts of first complex number: "; 24 | cin >> num1.real >> num1.imag; 25 | 26 | // Input second complex number 27 | cout << "Enter real and imaginary parts of second complex number: "; 28 | cin >> num2.real >> num2.imag; 29 | 30 | // Add two complex numbers 31 | sum = addComplex(num1, num2); 32 | 33 | // Display the result 34 | cout << "Sum = " << sum.real << " + " << sum.imag << "i"; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/25_AI_HRIDYESH_KUMAR/solution_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class clock 4 | { 5 | int h,m,s; 6 | public: 7 | void get() 8 | { 9 | cout<<"\n Enter hour part::"; 10 | cin>>h; 11 | cout<<"\n Enter minute part::"; 12 | cin>>m; 13 | cout<<"\n Enter second part::"; 14 | cin>>s; 15 | } 16 | void disp() 17 | { 18 | cout< 2 | 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | // Constructor to initialize the complex number 10 | Complex(double r, double i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | // Function to add two complex numbers 16 | Complex add(const Complex& other) { 17 | double newReal = real + other.real; 18 | double newImaginary = imaginary + other.imaginary; 19 | return Complex(newReal, newImaginary); 20 | } 21 | 22 | // Function to display the complex number 23 | void display() { 24 | std::cout << real << " + " << imaginary << "i" << std::endl; 25 | } 26 | }; 27 | 28 | int main() { 29 | // Creating two complex numbers 30 | Complex num1(3.5, 2.5); 31 | Complex num2(1.2, 4.8); 32 | 33 | // Adding two complex numbers 34 | Complex sum = num1.add(num2); 35 | 36 | // Displaying the result 37 | std::cout << "Sum: "; 38 | sum.display(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/26_AI_Ishaan-Jha/sol_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Class to represent complex numbers 5 | class Complex { 6 | private: 7 | float real; 8 | float imag; 9 | 10 | public: 11 | // Constructor to initialize real and imaginary parts 12 | Complex(float r = 0.0, float i = 0.0) : real(r), imag(i) {} 13 | 14 | // Method to add two complex numbers 15 | Complex operator+(const Complex& other) { 16 | return Complex(real + other.real, imag + other.imag); 17 | } 18 | 19 | // Method to display a complex number 20 | void display() const { 21 | cout << real << " + " << imag << "i" << endl; 22 | } 23 | }; 24 | 25 | int main() { 26 | // Create two complex numbers 27 | Complex c1(3.5, 2.5); 28 | Complex c2(1.5, 4.5); 29 | 30 | // Add the two numbers 31 | Complex c3 = c1 + c2; 32 | 33 | // Display the result 34 | cout << "The sum of "; 35 | c1.display(); 36 | cout << "and "; 37 | c2.display(); 38 | cout << "is "; 39 | c3.display(); 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/RAGHUWARNA_19/COMPLEX_1.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | // Constructor to initialize the complex number 10 | Complex(double r, double i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | // Function to add two complex numbers 16 | Complex add(const Complex& other) { 17 | double newReal = real + other.real; 18 | double newImaginary = imaginary + other.imaginary; 19 | return Complex(newReal, newImaginary); 20 | } 21 | 22 | // Function to display the complex number 23 | void display() { 24 | std::cout << real << " + " << imaginary << "i" << std::endl; 25 | } 26 | }; 27 | 28 | int main() { 29 | // Creating two complex numbers 30 | Complex num1(3.5, 2.5); 31 | Complex num2(1.2, 4.8); 32 | 33 | // Adding two complex numbers 34 | Complex sum = num1.add(num2); 35 | 36 | // Displaying the result 37 | std::cout << "Sum: "; 38 | sum.display(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Assignment_5/Problem.md: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | class Complex 8 | 9 | { 10 | 11 | private: 12 | 13 | int real, imag; 14 | 15 | public: 16 | 17 | Complex(int r = 0, int i =0) 18 | 19 | { real = r; imag = i; } 20 | 21 | friend ostream & operator << (ostream &out, const Complex &c); 22 | 23 | friend istream & operator >> (istream &in, Complex &c); 24 | 25 | }; 26 | 27 | 28 | 29 | ostream & operator << (ostream &out, const Complex &c) 30 | 31 | { 32 | 33 | out << c.real; 34 | 35 | out << "+i" << c.imag << endl; 36 | 37 | return out; 38 | 39 | } 40 | 41 | 42 | 43 | istream & operator >> (istream &in, Complex &c) 44 | 45 | { 46 | 47 | cout << "Enter Real Part "; 48 | 49 | in >> c.real; 50 | 51 | cout << "Enter Imaginary Part "; 52 | 53 | in >> c.imag; 54 | 55 | return in; 56 | 57 | } 58 | 59 | 60 | 61 | int main() 62 | 63 | { 64 | 65 | Complex c1; 66 | 67 | cin >> c1; 68 | 69 | cout << "The complex object is "; 70 | 71 | cout << c1; 72 | 73 | return 0; 74 | 75 | }# Write a c++ program for operator overloading extraction and insertion operator 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Gagan_Hemang_12/SOL_1.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | // Constructor to initialize the complex number 10 | Complex(double r, double i) { 11 | real = r; 12 | imaginary = i; 13 | } 14 | 15 | // Function to add two complex numbers 16 | Complex add(const Complex& other) { 17 | double newReal = real + other.real; 18 | double newImaginary = imaginary + other.imaginary; 19 | return Complex(newReal, newImaginary); 20 | } 21 | 22 | // Function to display the complex number 23 | void display() { 24 | std::cout << real << " + " << imaginary << "i" << std::endl; 25 | } 26 | }; 27 | 28 | int main() { 29 | // Creating two complex numbers 30 | Complex num1(3.5, 2.5); 31 | Complex num2(1.2, 4.8); 32 | 33 | // Adding two complex numbers 34 | Complex sum = num1.add(num2); 35 | 36 | // Displaying the result 37 | std::cout << "Sum: "; 38 | sum.display(); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/17_Dipanshu_Gupta/add_hour_min_sec.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int sec_prev=0; 8 | while(1) 9 | { 10 | int seconds, minutes, hours; 11 | string str; 12 | 13 | //storing total seconds 14 | time_t total_seconds=time(0); 15 | 16 | //getting values of seconds, minutes and hours 17 | struct tm* ct=localtime(&total_seconds); 18 | 19 | seconds=ct->tm_sec; 20 | minutes=ct->tm_min; 21 | hours=ct->tm_hour; 22 | 23 | //converting it into 12 hour format 24 | if(hours>=12) 25 | str="PM"; 26 | else 27 | str="AM"; 28 | hours=hours>12?hours-12:hours; 29 | 30 | 31 | //printing the result 32 | if(seconds==sec_prev+1 || (sec_prev==59 && seconds==0)) 33 | { 34 | system("CLS"); 35 | cout<< (hours<10?"0":"") << hours <<":" << (minutes<10?"0":"") << minutes << ":" << (seconds<10?"0":"") << seconds << " " << str < 2 | using namespace std; 3 | 4 | 5 | class Complex 6 | { 7 | public: int real, imaginary; 8 | Complex(int tempReal = 0, 9 | int tempImaginary = 0) 10 | { 11 | real = tempReal; 12 | imaginary = tempImaginary; 13 | } 14 | Complex addComp(Complex C1, Complex C2) 15 | { 16 | Complex temp; 17 | temp.real = C1.real + C2.real; 18 | temp.imaginary = (C1.imaginary + C2.imaginary); 19 | 20 | return temp; 21 | } 22 | }; 23 | 24 | int main() 25 | { 26 | Complex C1(3, 2); 27 | cout << "Complex number 1 : " << 28 | C1.real << " + i" << 29 | C1.imaginary << endl; 30 | Complex C2(9, 5); 31 | cout << "Complex number 2 : " << 32 | C2.real << " + i" << 33 | C2.imaginary << endl; 34 | Complex C3; 35 | C3 = C3.addComp(C1, C2); 36 | 37 | cout << "Sum of complex number : " << 38 | C3.real << " + i" << 39 | C3.imaginary; 40 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Ketan_Dinkar_Ai/Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | 13 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 14 | void displayTime() { 15 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 16 | } 17 | Time addTime(Time t) { 18 | Time sum; 19 | sum.seconds = seconds + t.seconds; 20 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 21 | sum.hours = hours + t.hours + sum.minutes / 60; 22 | sum.minutes %= 60; 23 | sum.seconds %= 60; 24 | return sum; 25 | } 26 | }; 27 | 28 | int main() { 29 | Time time1(2, 30, 45); 30 | Time time2(1, 45, 15); 31 | cout << "Original Time 1: "; 32 | time1.displayTime(); 33 | cout << "Original Time 2: "; 34 | time2.displayTime(); 35 | Time sum = time1.addTime(time2); 36 | cout << "Sum of Time 1 and Time 2: "; 37 | sum.displayTime(); 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Sanjay_singh/Hourmin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | 13 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 14 | void displayTime() { 15 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 16 | } 17 | Time addTime(Time t) { 18 | Time sum; 19 | sum.seconds = seconds + t.seconds; 20 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 21 | sum.hours = hours + t.hours + sum.minutes / 60; 22 | sum.minutes %= 60; 23 | sum.seconds %= 60; 24 | return sum; 25 | } 26 | }; 27 | 28 | int main() { 29 | Time time1(2, 30, 45); 30 | Time time2(1, 45, 15); 31 | cout << "Original Time 1: "; 32 | time1.displayTime(); 33 | cout << "Original Time 2: "; 34 | time2.displayTime(); 35 | Time sum = time1.addTime(time2); 36 | cout << "Sum of Time 1 and Time 2: "; 37 | sum.displayTime(); 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Shobha_Ai_60/Hourmin.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | 13 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 14 | void displayTime() { 15 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 16 | } 17 | Time addTime(Time t) { 18 | Time sum; 19 | sum.seconds = seconds + t.seconds; 20 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 21 | sum.hours = hours + t.hours + sum.minutes / 60; 22 | sum.minutes %= 60; 23 | sum.seconds %= 60; 24 | return sum; 25 | } 26 | }; 27 | 28 | int main() { 29 | Time time1(2, 30, 45); 30 | Time time2(1, 45, 15); 31 | cout << "Original Time 1: "; 32 | time1.displayTime(); 33 | cout << "Original Time 2: "; 34 | time2.displayTime(); 35 | Time sum = time1.addTime(time2); 36 | cout << "Sum of Time 1 and Time 2: "; 37 | sum.displayTime(); 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/45_Rahul_Sahu/time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | 13 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 14 | void displayTime() { 15 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 16 | } 17 | Time addTime(Time t) { 18 | Time sum; 19 | sum.seconds = seconds + t.seconds; 20 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 21 | sum.hours = hours + t.hours + sum.minutes / 60; 22 | sum.minutes %= 60; 23 | sum.seconds %= 60; 24 | return sum; 25 | } 26 | }; 27 | 28 | int main() { 29 | Time time1(2, 30, 45); 30 | Time time2(1, 45, 15); 31 | cout << "Original Time 1: "; 32 | time1.displayTime(); 33 | cout << "Original Time 2: "; 34 | time2.displayTime(); 35 | Time sum = time1.addTime(time2); 36 | cout << "Sum of Time 1 and Time 2: "; 37 | sum.displayTime(); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Bhumika shriwas 14/this_pointer.cpp: -------------------------------------------------------------------------------- 1 | /*The ‘this’ pointer is passed as a hidden argument to all nonstatic member function calls and is available as a local variable within the body of all nonstatic functions. ‘this’ pointer is not available in static member functions as static member functions can be called without any object with class name. 2 | The this pointer is a pointer accessible only within the nonstatic member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions don't have a this pointer. 3 | Syntax: 4 | this 5 | this->member-identifier*/ 6 | 7 | 8 | 9 | //PROGRAM 10 | #include 11 | 12 | using namespace std; 13 | 14 | class Test 15 | { 16 | 17 | private: 18 | 19 | int x; 20 | 21 | public: 22 | 23 | void setX (int x) 24 | 25 | { 26 | this->x = x; 27 | 28 | } 29 | 30 | void print() { cout << "x = " << x << endl; } 31 | }; 32 | 33 | 34 | 35 | int main() 36 | { 37 | 38 | Test obj; 39 | 40 | int x = 20; 41 | 42 | obj.setX(x); 43 | 44 | obj.print(); 45 | 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/62_ShubhangiPandey/sumoftime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hours; 6 | int minutes; 7 | int seconds; 8 | 9 | public: 10 | 11 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 12 | void displayTime() { 13 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 14 | } 15 | Time addTime(Time t) { 16 | Time sum; 17 | sum.seconds = seconds + t.seconds; 18 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 19 | sum.hours = hours + t.hours + sum.minutes / 60; 20 | sum.minutes %= 60; 21 | sum.seconds %= 60; 22 | return sum; 23 | } 24 | }; 25 | 26 | int main() { 27 | Time time1(2, 30, 45); 28 | Time time2(1, 45, 15); 29 | cout << "Original Time 1: "; 30 | time1.displayTime(); 31 | cout << "Original Time 2: "; 32 | time2.displayTime(); 33 | Time sum = time1.addTime(time2); 34 | cout << "Sum of Time 1 and Time 2: "; 35 | sum.displayTime(); 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Manaswi_Ai/hoursecondminute.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time { 5 | private: 6 | int hours; 7 | int minutes; 8 | int seconds; 9 | 10 | public: 11 | 12 | Time(int h = 0, int m = 0, int s = 0) : hours(h), minutes(m), seconds(s) {} 13 | void displayTime() { 14 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 15 | } 16 | Time addTime(Time t) { 17 | Time sum; 18 | sum.seconds = seconds + t.seconds; 19 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 20 | sum.hours = hours + t.hours + sum.minutes / 60; 21 | sum.minutes %= 60; 22 | sum.seconds %= 60; 23 | return sum; 24 | } 25 | }; 26 | 27 | int main() { 28 | Time time1(2, 30, 45); 29 | Time time2(1, 45, 15); 30 | cout << "Original Time 1: "; 31 | time1.displayTime(); 32 | cout << "Original Time 2: "; 33 | time2.displayTime(); 34 | Time sum = time1.addTime(time2); 35 | cout << "Sum of Time 1 and Time 2: "; 36 | sum.displayTime(); 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/22_AI_Harsh_Sharma/insertion_extraction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Distance { 4 | private: 5 | int feet; 6 | int inches; 7 | public: 8 | Distance() { 9 | feet = 0; 10 | inches = 0; 11 | } 12 | Distance(int f, int i) { 13 | feet = f; 14 | inches = i; 15 | } 16 | friend ostream &operator<<( ostream &output, const Distance &D ) { 17 | output << "F : " << D.feet << ", I : " << D.inches; 18 | return output; 19 | } 20 | friend istream &operator>>( istream &input, Distance &D ) { 21 | input >> D.feet >> D.inches; 22 | return input; 23 | } 24 | }; 25 | int main() { 26 | Distance D1(11, 10), D2(5, 11), D3; 27 | cout << "Enter the value of object : " << endl; 28 | cin >> D3; 29 | cout << "First Distance : " << D1 << endl; 30 | cout << "Second Distance :" << D2 << endl; 31 | cout << "Third Distance :" << D3 << endl; 32 | return 0; 33 | } 34 | // Enter the value of object : 35 | // 70 36 | // 10 37 | // First Distance : F : 11, I : 10 38 | // Second Distance :F : 5, I : 11 39 | // Third Distance :F : 70, I : 10 40 | 41 | 42 | // === Code Execution Successful === -------------------------------------------------------------------------------- /Assisgnments/Submissions/44_AI_PrernaSakre/to_add_time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class time 4 | { 5 | private: 6 | int hr, min, sec; 7 | 8 | public: 9 | void get() 10 | { 11 | cout << "enter hours:"; 12 | cin >> hr; 13 | cout << "enter min"; 14 | cin >> min; 15 | cout << "enter second:"; 16 | cin >> sec; 17 | } 18 | void add(time c1, time c2) 19 | { 20 | hr = c1.hr + c2.hr; 21 | min = c1.min + c2.min; 22 | sec = c1.sec + c2.sec; 23 | } 24 | void showtime(); 25 | void normalize(); 26 | }; 27 | void time::showtime() 28 | { 29 | cout << hr << ":" << min << ":" << sec << endl; 30 | } 31 | void time::normalize() 32 | { 33 | min = min + sec / 60; 34 | sec = sec % 60; 35 | hr = hr + min / 60; 36 | min = min % 60; 37 | } 38 | 39 | int main() 40 | { 41 | time t1, t2, t3; 42 | t1.get(); 43 | t1.showtime(); 44 | t1.normalize(); 45 | 46 | t2.get(); 47 | t2.showtime(); 48 | t2.normalize(); 49 | 50 | t3.add(t1, t2); 51 | t3.normalize(); 52 | t3.showtime(); 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/56_AI_Sharad_Singh_Thakur/add_time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int day = 0; 6 | class Time 7 | { 8 | int seconds; 9 | int minutes; 10 | int hours; 11 | 12 | public: 13 | 14 | 15 | void read() 16 | { 17 | cin>>hours>>minutes>>seconds; 18 | 19 | 20 | } 21 | 22 | Time operator +(Time t2) 23 | { 24 | int carry; 25 | Time sum; 26 | sum.seconds=(seconds+t2.seconds)%60; 27 | carry=(seconds+t2.seconds)/60; 28 | sum.minutes=(minutes+t2.minutes+carry)%60; 29 | carry=(minutes+t2.minutes+carry)/60; 30 | sum.hours=(hours+t2.hours+carry)%24; 31 | if ((hours+t2.hours+carry) >= 24){ 32 | day++; 33 | } 34 | return sum; 35 | 36 | } 37 | 38 | void display() 39 | { 40 | cout<<"SUM = " << day <<" day(s) : " << hours <<" hours : "< 2 | using namespace std; 3 | 4 | class Point { 5 | private: 6 | int x, y; 7 | 8 | public: 9 | Point() : x(0), y(0) {} 10 | 11 | Point(int x, int y) : x(x), y(y) {} 12 | 13 | // Friend function to overload extraction operator 14 | friend istream& operator>>(istream& in, Point& point); 15 | 16 | // Friend function to overload insertion operator 17 | friend ostream& operator<<(ostream& out, const Point& point); 18 | }; 19 | 20 | // Overloading the extraction operator >> 21 | istream& operator>>(istream& in, Point& point) { 22 | cout << "Enter x coordinate: "; 23 | in >> point.x; 24 | cout << "Enter y coordinate: "; 25 | in >> point.y; 26 | return in; 27 | } 28 | 29 | // Overloading the insertion operator << 30 | ostream& operator<<(ostream& out, const Point& point) { 31 | out << "Point(" << point.x << ", " << point.y << ")"; 32 | return out; 33 | } 34 | 35 | int main() { 36 | Point p; 37 | cout << "Enter the coordinates of the point:" << std::endl; 38 | cin >> p; 39 | cout << "The point you entered is: " << p << std::endl; 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/25_AI_HRIDYESH_KUMAR/insertion&extractionOperator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Distance { 4 | private: 5 | int feet; 6 | int inches; 7 | public: 8 | Distance() { 9 | feet = 0; 10 | inches = 0; 11 | } 12 | Distance(int f, int i) { 13 | feet = f; 14 | inches = i; 15 | } 16 | friend ostream &operator<<( ostream &output, const Distance &D ) { 17 | output << "F : " << D.feet << ", I : " << D.inches; 18 | return output; 19 | } 20 | friend istream &operator>>( istream &input, Distance &D ) { 21 | input >> D.feet >> D.inches; 22 | return input; 23 | } 24 | }; 25 | int main() { 26 | Distance D1(11, 10), D2(5, 11), D3; 27 | cout << "Enter the value of object : " << endl; 28 | cin >> D3; 29 | cout << "First Distance : " << D1 << endl; 30 | cout << "Second Distance :" << D2 << endl; 31 | cout << "Third Distance :" << D3 << endl; 32 | return 0; 33 | } 34 | // Enter the value of object : 35 | // 70 36 | // 10 37 | // First Distance : F : 11, I : 10 38 | // Second Distance :F : 5, I : 11 39 | // Third Distance :F : 70, I : 10 40 | 41 | 42 | // === Code Execution Successful === 43 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Alka/Time addition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Time { 4 | private: 5 | int hours; 6 | int minutes; 7 | int seconds; 8 | 9 | public: 10 | // Constructor to initialize the time 11 | Time(int h, int m, int s) { 12 | hours = h; 13 | minutes = m; 14 | seconds = s; 15 | } 16 | 17 | // Function to add time 18 | void addTime(int h, int m, int s) { 19 | seconds += s; 20 | minutes += m + seconds / 60; 21 | hours += h + minutes / 60; 22 | 23 | seconds %= 60; 24 | minutes %= 60; 25 | hours %= 24; 26 | } 27 | 28 | // Function to display the time 29 | void displayTime() { 30 | std::cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << std::endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | // Creating a time object 36 | Time currentTime(10, 30, 45); 37 | 38 | // Adding time 39 | int addHours = 1; 40 | int addMinutes = 15; 41 | int addSeconds = 30; 42 | currentTime.addTime(addHours, addMinutes, addSeconds); 43 | 44 | // Displaying the updated time 45 | currentTime.displayTime(); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/PARDHIV_35/SOL_2.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Time { 4 | private: 5 | int hours; 6 | int minutes; 7 | int seconds; 8 | 9 | public: 10 | // Constructor to initialize the time 11 | Time(int h, int m, int s) { 12 | hours = h; 13 | minutes = m; 14 | seconds = s; 15 | } 16 | 17 | // Function to add time 18 | void addTime(int h, int m, int s) { 19 | seconds += s; 20 | minutes += m + seconds / 60; 21 | hours += h + minutes / 60; 22 | 23 | seconds %= 60; 24 | minutes %= 60; 25 | hours %= 24; 26 | } 27 | 28 | // Function to display the time 29 | void displayTime() { 30 | std::cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << std::endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | // Creating a time object 36 | Time currentTime(10, 30, 45); 37 | 38 | // Adding time 39 | int addHours = 1; 40 | int addMinutes = 15; 41 | int addSeconds = 30; 42 | currentTime.addTime(addHours, addMinutes, addSeconds); 43 | 44 | // Displaying the updated time 45 | currentTime.displayTime(); 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/RAGHUWARNA_19/TIME_2.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Time { 4 | private: 5 | int hours; 6 | int minutes; 7 | int seconds; 8 | 9 | public: 10 | // Constructor to initialize the time 11 | Time(int h, int m, int s) { 12 | hours = h; 13 | minutes = m; 14 | seconds = s; 15 | } 16 | 17 | // Function to add time 18 | void addTime(int h, int m, int s) { 19 | seconds += s; 20 | minutes += m + seconds / 60; 21 | hours += h + minutes / 60; 22 | 23 | seconds %= 60; 24 | minutes %= 60; 25 | hours %= 24; 26 | } 27 | 28 | // Function to display the time 29 | void displayTime() { 30 | std::cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << std::endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | // Creating a time object 36 | Time currentTime(10, 30, 45); 37 | 38 | // Adding time 39 | int addHours = 1; 40 | int addMinutes = 15; 41 | int addSeconds = 30; 42 | currentTime.addTime(addHours, addMinutes, addSeconds); 43 | 44 | // Displaying the updated time 45 | currentTime.displayTime(); 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/08_Anshul_Yadav/time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | Time() { 13 | hours = 0; 14 | minutes = 0; 15 | seconds = 0; 16 | } 17 | 18 | Time(int h, int m, int s) { 19 | hours = h; 20 | minutes = m; 21 | seconds = s; 22 | } 23 | 24 | void display() { 25 | cout << hours << ":" << minutes << ":" << seconds << endl; 26 | } 27 | 28 | Time add(Time t) { 29 | Time result; 30 | 31 | result.hours = hours + t.hours; 32 | result.minutes = minutes + t.minutes; 33 | result.seconds = seconds + t.seconds; 34 | 35 | if (result.seconds >= 60) { 36 | result.minutes++; 37 | result.seconds -= 60; 38 | } 39 | 40 | if (result.minutes >= 60) { 41 | result.hours++; 42 | result.minutes -= 60; 43 | } 44 | 45 | return result; 46 | } 47 | }; 48 | 49 | int main() { 50 | Time t1(1, 20, 30); 51 | Time t2(2, 30, 45); 52 | 53 | Time result = t1.add(t2); 54 | 55 | result.display(); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/66_tejas mishra/1.txt: -------------------------------------------------------------------------------- 1 | //c++ program toadd two complex number 2 | 3 | 4 | 5 | 6 | #include 7 | using namespace std; 8 | 9 | 10 | class Complex 11 | { 12 | 13 | public: int real, imaginary; 14 | 15 | 16 | Complex(int tempReal = 0, 17 | int tempImaginary = 0) 18 | { 19 | real = tempReal; 20 | imaginary = tempImaginary; 21 | } 22 | 23 | 24 | Complex addComp(Complex C1, Complex C2) 25 | { 26 | 27 | Complex temp; 28 | 29 | 30 | temp.real = C1.real + C2.real; 31 | 32 | 33 | temp.imaginary = (C1.imaginary + C2.imaginary); 34 | 35 | 36 | return temp; 37 | } 38 | }; 39 | 40 | 41 | int main() 42 | { 43 | // First Complex number 44 | Complex C1(3, 2); 45 | 46 | // printing first complex number 47 | cout << "Complex number 1 : " << 48 | C1.real << " + i" << 49 | C1.imaginary << endl; 50 | 51 | 52 | Complex C2(9, 5); 53 | 54 | 55 | cout << "Complex number 2 : " << 56 | C2.real << " + i" << 57 | C2.imaginary << endl; 58 | 59 | 60 | Complex C3; 61 | 62 | 63 | C3 = C3.addComp(C1, C2); 64 | 65 | 66 | cout << "Sum of complex number : " << 67 | C3.real << " + i" << 68 | C3.imaginary; 69 | } 70 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/06 AI AMAN BANJARE/Add_complexnum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Gagan_Hemang_12/SOL_2.CPP: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Time { 4 | private: 5 | int hours; 6 | int minutes; 7 | int seconds; 8 | 9 | public: 10 | // Constructor to initialize the time 11 | Time(int h, int m, int s) { 12 | hours = h; 13 | minutes = m; 14 | seconds = s; 15 | } 16 | 17 | // Function to add time 18 | void addTime(int h, int m, int s) { 19 | seconds += s; 20 | minutes += m + seconds / 60; 21 | hours += h + minutes / 60; 22 | 23 | seconds %= 60; 24 | minutes %= 60; 25 | hours %= 24; 26 | } 27 | 28 | // Function to display the time 29 | void displayTime() { 30 | std::cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << std::endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | // Creating a time object 36 | Time currentTime(10, 30, 45); 37 | 38 | // Adding time 39 | int addHours = 1; 40 | int addMinutes = 15; 41 | int addSeconds = 30; 42 | currentTime.addTime(addHours, addMinutes, addSeconds); 43 | 44 | // Displaying the updated time 45 | currentTime.displayTime(); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/66_tejas mishra/3.txt: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print_month(int year, int month) { 4 | const char* month_names[] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 5 | 6 | std::cout << "\n" << month_names[month] << " " << year << "\n"; 7 | std::cout << "Mo Tu We Th Fr Sa Su\n"; 8 | 9 | int weekday = (year * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + month * 306 + 5) % 7; 10 | int days_in_month = 0; 11 | 12 | switch (month) { 13 | case 4: case 6: case 9: case 11: 14 | days_in_month = 30; 15 | break; 16 | case 2: 17 | days_in_month = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; 18 | break; 19 | default: 20 | days_in_month = 31; 21 | } 22 | 23 | for (int i = 0; i < (weekday + days_in_month); i++) { 24 | if (i < weekday) 25 | std::cout << " "; 26 | else 27 | std::cout << (i - weekday + 1) << ((i + 1) % 7 ? " " : "\n"); 28 | } 29 | } 30 | 31 | void print_calendar(int year) { 32 | for (int month = 1; month <= 12; month++) { 33 | print_month(year, month); 34 | } 35 | } 36 | 37 | int main() { 38 | int year = 2024; 39 | print_calendar(year); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Ketan_Dinkar_Ai/Calander.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Sanjay_singh/Calander.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Shobha_Ai_60/Calander.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/45_Rahul_Sahu/calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/61_AI_ShreyanshPatel/Assignment_1_sol/Add_complexnum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/62_ShubhangiPandey/complexnumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Complex 4 | { 5 | private: 6 | double real; 7 | double imag; 8 | 9 | public: 10 | Complex add(const Complex &c) 11 | { 12 | Complex result; 13 | result.real = real + c.real; 14 | result.imag = imag + c.imag; 15 | return result; 16 | } 17 | 18 | void get(double real_input, double imag_input) 19 | { 20 | real = real_input; 21 | imag = imag_input; 22 | } 23 | 24 | void display() 25 | { 26 | cout << "Result: " << real << " + " << imag << "i" << endl; 27 | } 28 | }; 29 | 30 | int main() 31 | { 32 | 33 | Complex num1, num2; 34 | double r1, i1, r2, i2; 35 | 36 | cout << "For First Complex number, " << endl; 37 | cout << "Enter real part: "; 38 | cin >> r1; 39 | cout << "Enter imaginary part: "; 40 | cin >> i1; 41 | num1.get(r1, i1); 42 | 43 | cout << "For Second Complex number, " << endl; 44 | cout << "Enter real part: "; 45 | cin >> r2; 46 | cout << "Enter imaginary part: "; 47 | cin >> i2; 48 | num2.get(r2, i2); 49 | 50 | Complex sum = num1.add(num2); 51 | 52 | sum.display(); 53 | return 0; 54 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/17_Dipanshu_Gupta/add_two_complex_no.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | typedef struct complex { 5 | float real; 6 | float imag; 7 | } complexNumber; 8 | 9 | complexNumber addComplexNumbers(complex, complex); 10 | 11 | int main() { 12 | complexNumber num1, num2, complexSum; 13 | char signOfImag; 14 | 15 | cout << "For 1st complex number," << endl; 16 | cout << "Enter real and imaginary parts respectively:" << endl; 17 | cin >> num1.real >> num1.imag; 18 | 19 | cout << endl 20 | << "For 2nd complex number," << endl; 21 | cout << "Enter real and imaginary parts respectively:" << endl; 22 | cin >> num2.real >> num2.imag; 23 | 24 | 25 | complexSum = addComplexNumbers(num1, num2); 26 | 27 | 28 | signOfImag = (complexSum.imag > 0) ? '+' : '-'; 29 | 30 | 31 | complexSum.imag = (complexSum.imag > 0) ? complexSum.imag : -complexSum.imag; 32 | 33 | cout << "Sum = " << complexSum.real << signOfImag << complexSum.imag << "i"; 34 | 35 | return 0; 36 | } 37 | 38 | complexNumber addComplexNumbers(complex num1, complex num2) { 39 | complex temp; 40 | temp.real = num1.real + num2.real; 41 | temp.imag = num1.imag + num2.imag; 42 | return (temp); 43 | } 44 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Bhumi/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Bhumi/sumofcomplexnumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/31 AI KAVESH SAHU/Add_complexnum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/37_AI_Mohan_Sahu/Add_complex_num..cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/62_ShubhangiPandey/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Manaswi_Ai/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | 42 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Bhumika shriwas 14/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | int daysInMonth(int month, int year) { 9 | if (month == 2) { 10 | return isLeapYear(year) ? 29 : 28; 11 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 12 | return 30; 13 | } else { 14 | return 31; 15 | } 16 | } 17 | void printCalendar(int month, int year) { 18 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 19 | int firstDayOfWeek = (year - (14 - month) / 12) % 7; 20 | int daysInCurrentMonth = daysInMonth(month, year); 21 | for (int i = 0; i < firstDayOfWeek; ++i) { 22 | cout << setw(5) << " "; 23 | } 24 | for (int day = 1; day <= daysInCurrentMonth; ++day) { 25 | cout << setw(5) << day; 26 | if ((firstDayOfWeek + day) % 7 == 0 || day == daysInCurrentMonth) { 27 | cout << endl; 28 | } 29 | } 30 | } 31 | 32 | int main() { 33 | int month, year; 34 | cout << "Enter month (1-12): "; 35 | cin >> month; 36 | cout << "Enter year: "; 37 | cin >> year; 38 | printCalendar(month, year); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Bhumika shriwas 14/sumofcomplexnumber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Complex 5 | { 6 | private: 7 | double real; 8 | double imag; 9 | 10 | public: 11 | Complex add(const Complex &c) 12 | { 13 | Complex result; 14 | result.real = real + c.real; 15 | result.imag = imag + c.imag; 16 | return result; 17 | } 18 | 19 | void get(double real_input, double imag_input) 20 | { 21 | real = real_input; 22 | imag = imag_input; 23 | } 24 | 25 | void display() 26 | { 27 | cout << "Result: " << real << " + " << imag << "i" << endl; 28 | } 29 | }; 30 | 31 | int main() 32 | { 33 | 34 | Complex num1, num2; 35 | double r1, i1, r2, i2; 36 | 37 | cout << "For First Complex number, " << endl; 38 | cout << "Enter real part: "; 39 | cin >> r1; 40 | cout << "Enter imaginary part: "; 41 | cin >> i1; 42 | num1.get(r1, i1); 43 | 44 | cout << "For Second Complex number, " << endl; 45 | cout << "Enter real part: "; 46 | cin >> r2; 47 | cout << "Enter imaginary part: "; 48 | cin >> i2; 49 | num2.get(r2, i2); 50 | 51 | Complex sum = num1.add(num2); 52 | 53 | sum.display(); 54 | 55 | return 0; 56 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/68_Vasu_Dewangan/complex_no.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | class Complex 6 | { 7 | private: 8 | double real; 9 | double imag; 10 | 11 | public: 12 | Complex add(const Complex &c) 13 | { 14 | Complex result; 15 | result.real = real + c.real; 16 | result.imag = imag + c.imag; 17 | return result; 18 | } 19 | 20 | void get(double real_input, double imag_input) 21 | { 22 | real = real_input; 23 | imag = imag_input; 24 | } 25 | 26 | void display() 27 | { 28 | cout << "Result: " << real << " + " << imag << "i" << endl; 29 | } 30 | }; 31 | 32 | int main() 33 | { 34 | 35 | Complex num1, num2; 36 | double r1, i1, r2, i2; 37 | 38 | cout << "For First Complex number, " << endl; 39 | cout << "Enter real part: "; 40 | cin >> r1; 41 | cout << "Enter imaginary part: "; 42 | cin >> i1; 43 | num1.get(r1, i1); 44 | 45 | cout << "For Second Complex number, " << endl; 46 | cout << "Enter real part: "; 47 | cin >> r2; 48 | cout << "Enter imaginary part: "; 49 | cin >> i2; 50 | num2.get(r2, i2); 51 | 52 | Complex sum = num1.add(num2); 53 | 54 | sum.display(); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/67_tilak_Verma_#tasveer/complex_no.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | class Complex 6 | { 7 | private: 8 | double real; 9 | double imag; 10 | 11 | public: 12 | Complex add(const Complex &c) 13 | { 14 | Complex result; 15 | result.real = real + c.real; 16 | result.imag = imag + c.imag; 17 | return result; 18 | } 19 | 20 | void get(double real_input, double imag_input) 21 | { 22 | real = real_input; 23 | imag = imag_input; 24 | } 25 | 26 | void display() 27 | { 28 | cout << "Result: " << real << " + " << imag << "i" << endl; 29 | } 30 | }; 31 | 32 | int main() 33 | { 34 | 35 | Complex num1, num2; 36 | double r1, i1, r2, i2; 37 | 38 | cout << "For First Complex number, " << endl; 39 | cout << "Enter real part: "; 40 | cin >> r1; 41 | cout << "Enter imaginary part: "; 42 | cin >> i1; 43 | num1.get(r1, i1); 44 | 45 | cout << "For Second Complex number, " << endl; 46 | cout << "Enter real part: "; 47 | cin >> r2; 48 | cout << "Enter imaginary part: "; 49 | cin >> i2; 50 | num2.get(r2, i2); 51 | 52 | Complex sum = num1.add(num2); 53 | 54 | sum.display(); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/09_Anurag_Deshmukh/3_calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Time { 6 | private: 7 | int hours; 8 | int minutes; 9 | int seconds; 10 | 11 | public: 12 | // Constructor to initialize the time 13 | Time(int h, int m, int s) { 14 | hours = h; 15 | minutes = m; 16 | seconds = s; 17 | } 18 | 19 | // Function to add two time objects 20 | Time addTime(Time t) { 21 | Time sum(0, 0, 0); 22 | sum.seconds = seconds + t.seconds; 23 | sum.minutes = minutes + t.minutes + sum.seconds / 60; 24 | sum.hours = hours + t.hours + sum.minutes / 60; 25 | sum.minutes %= 60; 26 | sum.seconds %= 60; 27 | return sum; 28 | } 29 | 30 | // Function to display the time 31 | void displayTime() { 32 | cout << "Time: " << hours << " hours, " << minutes << " minutes, " << seconds << " seconds" << endl; 33 | } 34 | }; 35 | 36 | int main() { 37 | // Create two time objects 38 | Time t1(1, 30, 45); // 1 hour, 30 minutes, 45 seconds 39 | Time t2(2, 45, 30); // 2 hours, 45 minutes, 30 seconds 40 | 41 | // Add the two time objects 42 | Time sum = t1.addTime(t2); 43 | 44 | // Display the result 45 | cout << "Sum of times:" << endl; 46 | sum.displayTime(); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/39_AI_MOKSH/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/02_Abhinav_Anand/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/10_AI_ARNAV_JHA/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/22_AI_Harsh_Sharma/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/59_Shivani_Kumari/time_Add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/03_AI_Abhinav_Shukla/Time_add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Time { 4 | private: 5 | int hrs; 6 | int mint; 7 | int sec; 8 | 9 | public: 10 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mint(m), sec(s) {} 11 | 12 | void sett(int h, int m, int s) { 13 | hrs = h; 14 | mint = m; 15 | sec = s; 16 | } 17 | Time calctadd(const Time& endTime) const { 18 | Time tadd; 19 | int startsec = hrs * 3600 + mint * 60 + sec; 20 | int endsec = endTime.hrs * 3600 + endTime.mint * 60 + endTime.sec; 21 | int addt = endsec + startsec; 22 | tadd.hrs = addt / 3600; 23 | tadd.mint = (addt % 3600) / 60; 24 | tadd.sec = addt % 60; 25 | 26 | return addt; 27 | } 28 | 29 | void display() const { 30 | cout << hrs << " hrs, " << mint << " min, " << sec << " sec." << endl; 31 | } 32 | }; 33 | 34 | int main() { 35 | Time startTime, endTime; 36 | 37 | cout << "Enter start time (hrs min sec): "; 38 | int h, m, s; 39 | cin >> h >> m >> s; 40 | startTime.sett(h, m, s); 41 | 42 | cout << "Enter end time (hrs min sec): "; 43 | cin >> h >> m >> s; 44 | endTime.sett(h, m, s); 45 | 46 | Time tadd = startTime.calctadd(endTime); 47 | 48 | cout << "Time Addition: "; 49 | tadd.display(); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/17_Dipanshu_Gupta/calendar_2024.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print_month(int year, int month) { 4 | const char* month_names[] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 5 | 6 | std::cout << "\n" << month_names[month] << " " << year << "\n"; 7 | std::cout << "Mo Tu We Th Fr Sa Su\n"; 8 | 9 | int weekday = (year * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + month * 306 + 5) % 7; 10 | int days_in_month = 0; 11 | 12 | switch (month) { 13 | case 4: case 6: case 9: case 11: 14 | days_in_month = 30; 15 | break; 16 | case 2: 17 | days_in_month = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; 18 | break; 19 | default: 20 | days_in_month = 31; 21 | } 22 | 23 | for (int i = 0; i < (weekday + days_in_month); i++) { 24 | if (i < weekday) 25 | std::cout << " "; 26 | else 27 | std::cout << (i - weekday + 1) << ((i + 1) % 7 ? " " : "\n"); 28 | } 29 | } 30 | 31 | void print_calendar(int year) { 32 | for (int month = 1; month <= 12; month++) { 33 | print_month(year, month); 34 | } 35 | } 36 | 37 | int main() { 38 | int year = 2024; 39 | print_calendar(year); 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/300012723057__CSE(AI)__SHIVAM CHOUDHARY/calender2024.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void print_month(int year, int month) { 4 | const char* month_names[] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 5 | 6 | std::cout << "\n" << month_names[month] << " " << year << "\n"; 7 | std::cout << "Mo Tu We Th Fr Sa Su\n"; 8 | 9 | int weekday = (year * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400 + month * 306 + 5) % 7; 10 | int days_in_month = 0; 11 | 12 | switch (month) { 13 | case 4: case 6: case 9: case 11: 14 | days_in_month = 30; 15 | break; 16 | case 2: 17 | days_in_month = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; 18 | break; 19 | default: 20 | days_in_month = 31; 21 | } 22 | 23 | for (int i = 0; i < (weekday + days_in_month); i++) { 24 | if (i < weekday) 25 | std::cout << " "; 26 | else 27 | std::cout << (i - weekday + 1) << ((i + 1) % 7 ? " " : "\n"); 28 | } 29 | } 30 | void print_calendar(int year) { 31 | for (int month = 1; month <= 12; month++) { 32 | print_month(year, month); 33 | } 34 | } 35 | 36 | int main() { 37 | int year = 2024; 38 | print_calendar(year); 39 | return 0; 40 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Kanchan_Patel_AI_29/time_addition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Function to add time 6 | void addTime(int &hours, int &minutes, int &seconds, int addHours, int addMinutes, int addSeconds) { 7 | // Add seconds 8 | seconds += addSeconds; 9 | 10 | // If seconds overflow, adjust minutes and seconds 11 | if (seconds >= 60) { 12 | minutes += seconds / 60; 13 | seconds %= 60; 14 | } 15 | 16 | // Add minutes 17 | minutes += addMinutes; 18 | 19 | // If minutes overflow, adjust hours and minutes 20 | if (minutes >= 60) { 21 | hours += minutes / 60; 22 | minutes %= 60; 23 | } 24 | 25 | // Add hours 26 | hours += addHours; 27 | } 28 | 29 | int main() { 30 | int hours, minutes, seconds; 31 | int addHours, addMinutes, addSeconds; 32 | 33 | // Input current time 34 | cout << "Enter current time (hh mm ss): "; 35 | cin >> hours >> minutes >> seconds; 36 | 37 | // Input time to add 38 | cout << "Enter time to add (hh mm ss): "; 39 | cin >> addHours >> addMinutes >> addSeconds; 40 | 41 | // Add time 42 | addTime(hours, minutes, seconds, addHours, addMinutes, addSeconds); 43 | 44 | // Display updated time 45 | cout << "Updated time: " << hours << " hours " << minutes << " minutes " << seconds << " seconds"; 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Suleman_lakra_AI_64/time_addition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Function to add time 6 | void addTime(int &hours, int &minutes, int &seconds, int addHours, int addMinutes, int addSeconds) { 7 | // Add seconds 8 | seconds += addSeconds; 9 | 10 | // If seconds overflow, adjust minutes and seconds 11 | if (seconds >= 60) { 12 | minutes += seconds / 60; 13 | seconds %= 60; 14 | } 15 | 16 | // Add minutes 17 | minutes += addMinutes; 18 | 19 | // If minutes overflow, adjust hours and minutes 20 | if (minutes >= 60) { 21 | hours += minutes / 60; 22 | minutes %= 60; 23 | } 24 | 25 | // Add hours 26 | hours += addHours; 27 | } 28 | 29 | int main() { 30 | int hours, minutes, seconds; 31 | int addHours, addMinutes, addSeconds; 32 | 33 | // Input current time 34 | cout << "Enter current time (hh mm ss): "; 35 | cin >> hours >> minutes >> seconds; 36 | 37 | // Input time to add 38 | cout << "Enter time to add (hh mm ss): "; 39 | cin >> addHours >> addMinutes >> addSeconds; 40 | 41 | // Add time 42 | addTime(hours, minutes, seconds, addHours, addMinutes, addSeconds); 43 | 44 | // Display updated time 45 | cout << "Updated time: " << hours << " hours " << minutes << " minutes " << seconds << " seconds"; 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/38_AI_Mohnish_pradhan/solution_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Time { 6 | int hours; 7 | int minutes; 8 | int seconds; 9 | }; 10 | 11 | 12 | Time addTime(const Time& t1, const Time& t2) { 13 | Time sum; 14 | int extraMinutes = 0; 15 | int extraHours = 0; 16 | 17 | 18 | sum.seconds = t1.seconds + t2.seconds; 19 | if (sum.seconds >= 60) { 20 | extraMinutes = sum.seconds / 60; 21 | sum.seconds %= 60; 22 | } 23 | 24 | 25 | sum.minutes = t1.minutes + t2.minutes + extraMinutes; 26 | if (sum.minutes >= 60) { 27 | extraHours = sum.minutes / 60; 28 | sum.minutes %= 60; 29 | } 30 | 31 | 32 | sum.hours = t1.hours + t2.hours + extraHours; 33 | 34 | return sum; 35 | } 36 | 37 | 38 | void displayTime(const Time& t) { 39 | cout << "Time: " << t.hours << " hours " << t.minutes << " minutes " << t.seconds << " seconds\n"; 40 | } 41 | 42 | int main() { 43 | Time time1, time2, totalTime; 44 | 45 | 46 | cout << "Enter the first time (hours minutes seconds): "; 47 | cin >> time1.hours >> time1.minutes >> time1.seconds; 48 | 49 | cout << "Enter the second time (hours minutes seconds): "; 50 | cin >> time2.hours >> time2.minutes >> time2.seconds; 51 | 52 | 53 | totalTime = addTime(time1, time2); 54 | 55 | 56 | displayTime(totalTime); 57 | 58 | return 0; 59 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Rupali/This Pointer.cpp: -------------------------------------------------------------------------------- 1 | //this pointer program 2 | 3 | #include 4 | using namespace std; 5 | 6 | class Rectangle { 7 | private: 8 | int length; 9 | int width; 10 | 11 | public: 12 | // Constructor 13 | Rectangle(int length, int width) { 14 | // Using this pointer to distinguish between member variables and parameters 15 | this->length = length; 16 | this->width = width; 17 | } 18 | 19 | // Member function to set dimensions 20 | Rectangle& setDimensions(int length, int width) { 21 | this->length = length; 22 | this->width = width; 23 | return *this; // Returning the current object to enable chaining 24 | } 25 | 26 | // Member function to calculate area 27 | int area() { 28 | return this->length * this->width; // Using this pointer explicitly 29 | } 30 | 31 | // Member function to display dimensions 32 | void display() { 33 | cout << "Length: " << this->length << ", Width: " << this->width << endl; 34 | } 35 | }; 36 | 37 | int main() { 38 | // Creating an object of Rectangle 39 | Rectangle rect(10, 5); 40 | 41 | // Displaying initial dimensions and area 42 | rect.display(); 43 | cout << "Initial Area: " << rect.area() << endl; 44 | 45 | // Using setDimensions function with method chaining 46 | rect.setDimensions(20, 10).display(); 47 | 48 | // Displaying new area 49 | cout << "New Area: " << rect.area() << endl; 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/10_AI_ARNAV_JHA/extraction_insertion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | class Complex { 4 | private: 5 | double real; 6 | double imaginary; 7 | 8 | public: 9 | Complex(double real = 0.0, double imaginary = 0.0) { 10 | this->real = real; 11 | this->imaginary = imaginary; 12 | } 13 | 14 | friend ostream& operator<<( ostream& os, const Complex& c) { 15 | os << c.real << " + " << c.imaginary << "i"; 16 | return os; 17 | } 18 | 19 | friend istream& operator>>( istream& is, Complex& c) { 20 | cout << "Enter real part: "; 21 | cout << "Enter real part: "; 22 | is >> c.real; 23 | cout << "Enter imaginary part: "; 24 | is >> c.imaginary; 25 | return is; 26 | } 27 | }; 28 | 29 | int main() { 30 | Complex c1; 31 | cout << "Enter a complex number: "; 32 | cin >> c1; 33 | cout << "The complex number you entered is: " << c1 << endl; 34 | 35 | return 0; 36 | } 37 | Complex operator>>(Complex& c, istream& is) { 38 | cout << "Enter real part: "; 39 | is >> c.real; 40 | cout << "Enter imaginary part: "; 41 | is >> c.imaginary; 42 | return c; 43 | } 44 | 45 | void operator<<(const Complex& c, ostream& os) { 46 | os << c.real << " + " << c.imaginary << "i"; 47 | } 48 | 49 | int main() { 50 | Complex c1; 51 | cout << "Enter a complex number: "; 52 | c1 >> cin; 53 | cout << "The complex number you entered is: "; 54 | c1 << cout; 55 | cout << endl; 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/25_AI_HRIDYESH_KUMAR/solution_3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | bool isLeapYear(int year) { 4 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 5 | } 6 | int daysInMonth(int month, int year) { 7 | switch (month) { 8 | case 2: 9 | return isLeapYear(year) ? 29 : 28; 10 | case 4: 11 | case 6: 12 | case 9: 13 | case 11: 14 | return 30; 15 | default: 16 | return 31; 17 | } 18 | } 19 | void printCalendar(int month, int year) { 20 | std::cout << std::setw(20) << std::setfill(' ') << std::right << month << " " << year << std::endl; 21 | std::cout << " Sun Mon Tue Wed Thu Fri Sat" << std::endl; 22 | int startDay = 1; 23 | for (int i = 1900; i < year; ++i) { 24 | startDay += isLeapYear(i) ? 366 : 365; 25 | } 26 | for (int i = 1; i < month; ++i) { 27 | startDay += daysInMonth(i, year); 28 | } 29 | startDay %= 7; 30 | for (int i = 0; i < startDay; ++i) { 31 | std::cout << std::setw(5) << " "; 32 | } 33 | int days = daysInMonth(month, year); 34 | for (int day = 1; day <= days; ++day) { 35 | std::cout << std::setw(5) << day; 36 | if ((startDay + day) % 7 == 0) { 37 | std::cout << std::endl; 38 | } 39 | } 40 | std::cout << std::endl; 41 | } 42 | int main() { 43 | int year = 2024; 44 | for (int month = 1; month <= 12; ++month) { 45 | printCalendar(month, year); 46 | std::cout << std::endl; 47 | } 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/13_Bhooma_Anand/3_calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Function to check if a given year is a leap year 6 | bool isLeapYear(int year) { 7 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 8 | } 9 | 10 | // Function to print a basic calendar for a given year 11 | void printCalendar(int year) { 12 | const int daysInMonth[] = {31, 28 + isLeapYear(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 13 | const string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 14 | 15 | cout << "Calendar for the year " << year << ":" << endl; 16 | 17 | for (int month = 0; month < 12; ++month) { 18 | cout << "\n=========================\n"; 19 | cout << months[month] << " " << year << "\n"; 20 | cout << "=========================\n\n"; 21 | 22 | cout << " Sun Mon Tue Wed Thu Fri Sat\n"; 23 | 24 | // Calculate the day of the week for the first day of the month 25 | int firstDay = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 26 | for (int i = 0; i < firstDay; ++i) { 27 | cout << " "; 28 | } 29 | 30 | for (int day = 1; day <= daysInMonth[month]; ++day) { 31 | cout.width(4); 32 | cout << day; 33 | firstDay = (firstDay + 1) % 7; 34 | if (firstDay == 0) { 35 | cout << endl; 36 | } 37 | } 38 | cout << endl; 39 | } 40 | } 41 | 42 | int main() { 43 | int year = 2024; 44 | printCalendar(year); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/06 AI AMAN BANJARE/AddTime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time 5 | { 6 | private: 7 | int hrs; 8 | int mins; 9 | int secs; 10 | 11 | public: 12 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 13 | 14 | void setTime(int h, int m, int s) 15 | { 16 | hrs = h; 17 | mins = m; 18 | secs = s; 19 | } 20 | 21 | Time sum(const Time &t2) const 22 | { 23 | int totalHrs = hrs + t2.hrs; 24 | int totalMins = mins + t2.mins; 25 | int totalSecs = secs + t2.secs; 26 | 27 | if (totalSecs >= 60) 28 | { 29 | totalMins += totalSecs / 60; 30 | totalSecs %= 60; 31 | } 32 | if (totalMins >= 60) 33 | { 34 | totalHrs += totalMins / 60; 35 | totalMins %= 60; 36 | } 37 | 38 | return Time(totalHrs, totalMins, totalSecs); 39 | } 40 | 41 | void display() const 42 | { 43 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | int H1, M1, S1, H2, M2, S2; 50 | 51 | cout << "Enter first time: "<< endl << "Hrs: "; 52 | cin >> H1; 53 | cout<<"Mins: "; 54 | cin >> M1; 55 | cout<<"Secs: "; 56 | cin >> S1; 57 | 58 | cout << "Enter second time: "<< endl << "Hrs :"; 59 | cin >> H2; 60 | cout<<"Mins: "; 61 | cin >> M2; 62 | cout<<"Secs: "; 63 | cin >> S2; 64 | 65 | Time time1(H1, M1, S1); 66 | Time time2(H2, M2, S2); 67 | 68 | Time totalTime = time1.sum(time2); 69 | 70 | totalTime.display(); 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/61_AI_ShreyanshPatel/Assignment_1_sol/Addtime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time 5 | { 6 | private: 7 | int hrs; 8 | int mins; 9 | int secs; 10 | 11 | public: 12 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 13 | 14 | void setTime(int h, int m, int s) 15 | { 16 | hrs = h; 17 | mins = m; 18 | secs = s; 19 | } 20 | 21 | Time sum(const Time &t2) const 22 | { 23 | int totalHrs = hrs + t2.hrs; 24 | int totalMins = mins + t2.mins; 25 | int totalSecs = secs + t2.secs; 26 | 27 | if (totalSecs >= 60) 28 | { 29 | totalMins += totalSecs / 60; 30 | totalSecs %= 60; 31 | } 32 | if (totalMins >= 60) 33 | { 34 | totalHrs += totalMins / 60; 35 | totalMins %= 60; 36 | } 37 | 38 | return Time(totalHrs, totalMins, totalSecs); 39 | } 40 | 41 | void display() const 42 | { 43 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | int H1, M1, S1, H2, M2, S2; 50 | 51 | cout << "Enter first time: "<< endl << "Hrs: "; 52 | cin >> H1; 53 | cout<<"Mins: "; 54 | cin >> M1; 55 | cout<<"Secs: "; 56 | cin >> S1; 57 | 58 | cout << "Enter second time: "<< endl << "Hrs :"; 59 | cin >> H2; 60 | cout<<"Mins: "; 61 | cin >> M2; 62 | cout<<"Secs: "; 63 | cin >> S2; 64 | 65 | Time time1(H1, M1, S1); 66 | Time time2(H2, M2, S2); 67 | 68 | Time totalTime = time1.sum(time2); 69 | 70 | totalTime.display(); 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/26_AI_Ishaan-Jha/sol_2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Time { 6 | int hours; 7 | int minutes; 8 | int seconds; 9 | }; 10 | 11 | // Function to add two time periods 12 | Time addTime(const Time& t1, const Time& t2) { 13 | Time sum; 14 | int extraMinutes = 0; 15 | int extraHours = 0; 16 | 17 | // Add seconds and handle overflow 18 | sum.seconds = t1.seconds + t2.seconds; 19 | if (sum.seconds >= 60) { 20 | extraMinutes = sum.seconds / 60; 21 | sum.seconds %= 60; 22 | } 23 | 24 | // Add minutes and handle overflow 25 | sum.minutes = t1.minutes + t2.minutes + extraMinutes; 26 | if (sum.minutes >= 60) { 27 | extraHours = sum.minutes / 60; 28 | sum.minutes %= 60; 29 | } 30 | 31 | // Add hours 32 | sum.hours = t1.hours + t2.hours + extraHours; 33 | 34 | return sum; 35 | } 36 | 37 | // Function to display time in a proper format 38 | void displayTime(const Time& t) { 39 | cout << "Time: " << t.hours << " hours " << t.minutes << " minutes " << t.seconds << " seconds\n"; 40 | } 41 | 42 | int main() { 43 | Time time1, time2, totalTime; 44 | 45 | // Get the first time input 46 | cout << "Enter the first time (hours minutes seconds): "; 47 | cin >> time1.hours >> time1.minutes >> time1.seconds; 48 | 49 | // Get the second time input 50 | cout << "Enter the second time (hours minutes seconds): "; 51 | cin >> time2.hours >> time2.minutes >> time2.seconds; 52 | 53 | // Add times 54 | totalTime = addTime(time1, time2); 55 | 56 | // Display the result 57 | displayTime(totalTime); 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/shaikhidayathulla_55/ASS1.CPP: -------------------------------------------------------------------------------- 1 | // C++ Program to Add 2 | // Two Complex Numbers 3 | 4 | // Importing all libraries 5 | #include 6 | using namespace std; 7 | 8 | // User Defined Complex class 9 | class Complex 10 | { 11 | // Declaring variables 12 | public: int real, imaginary; 13 | 14 | // Constructor to accept 15 | // real and imaginary part 16 | Complex(int tempReal = 0, 17 | int tempImaginary = 0) 18 | { 19 | real = tempReal; 20 | imaginary = tempImaginary; 21 | } 22 | 23 | // Defining addComp() method 24 | // for adding two complex number 25 | Complex addComp(Complex C1, Complex C2) 26 | { 27 | // Creating temporary variable 28 | Complex temp; 29 | 30 | // Adding real part of 31 | // complex numbers 32 | temp.real = C1.real + C2.real; 33 | 34 | // Adding Imaginary part of 35 | // complex numbers 36 | temp.imaginary = (C1.imaginary + C2.imaginary); 37 | 38 | // Returning the sum 39 | return temp; 40 | } 41 | }; 42 | 43 | // Driver code 44 | int main() 45 | { 46 | // First Complex number 47 | Complex C1(3, 2); 48 | 49 | // printing first complex number 50 | cout << "Complex number 1 : " << 51 | C1.real << " + i" << 52 | C1.imaginary << endl; 53 | 54 | // Second Complex number 55 | Complex C2(9, 5); 56 | 57 | // Printing second complex number 58 | cout << "Complex number 2 : " << 59 | C2.real << " + i" << 60 | C2.imaginary << endl; 61 | 62 | // For Storing the sum 63 | Complex C3; 64 | 65 | // Calling addComp() method 66 | C3 = C3.addComp(C1, C2); 67 | 68 | // Printing the sum 69 | cout << "Sum of complex number : " << 70 | C3.real << " + i" << 71 | C3.imaginary; 72 | } 73 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/31 AI KAVESH SAHU/AddTime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time 5 | { 6 | private: 7 | int hrs; 8 | int mins; 9 | int secs; 10 | 11 | public: 12 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 13 | 14 | void setTime(int h, int m, int s) 15 | { 16 | hrs = h; 17 | mins = m; 18 | secs = s; 19 | } 20 | 21 | Time sum(const Time &t2) const 22 | { 23 | int totalHrs = hrs + t2.hrs; 24 | int totalMins = mins + t2.mins; 25 | int totalSecs = secs + t2.secs; 26 | 27 | if (totalSecs >= 60) 28 | { 29 | totalMins += totalSecs / 60; 30 | totalSecs %= 60; 31 | } 32 | if (totalMins >= 60) 33 | { 34 | totalHrs += totalMins / 60; 35 | totalMins %= 60; 36 | } 37 | 38 | return Time(totalHrs, totalMins, totalSecs); 39 | } 40 | 41 | void display() const 42 | { 43 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | int H1, M1, S1, H2, M2, S2; 50 | 51 | cout << "Enter first time: "<< endl << "Hrs: "; 52 | cin >> H1; 53 | cout<<"Mins: "; 54 | cin >> M1; 55 | cout<<"Secs: "; 56 | cin >> S1; 57 | 58 | cout << "Enter second time: "<< endl << "Hrs :"; 59 | cin >> H2; 60 | cout<<"Mins: "; 61 | cin >> M2; 62 | cout<<"Secs: "; 63 | cin >> S2; 64 | 65 | Time time1(H1, M1, S1); 66 | Time time2(H2, M2, S2); 67 | 68 | Time totalTime = time1.sum(time2); 69 | 70 | totalTime.display(); 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/37_AI_Mohan_Sahu/Add_Time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Time 5 | { 6 | private: 7 | int hrs; 8 | int mins; 9 | int secs; 10 | 11 | public: 12 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 13 | 14 | void setTime(int h, int m, int s) 15 | { 16 | hrs = h; 17 | mins = m; 18 | secs = s; 19 | } 20 | 21 | Time sum(const Time &t2) const 22 | { 23 | int totalHrs = hrs + t2.hrs; 24 | int totalMins = mins + t2.mins; 25 | int totalSecs = secs + t2.secs; 26 | 27 | if (totalSecs >= 60) 28 | { 29 | totalMins += totalSecs / 60; 30 | totalSecs %= 60; 31 | } 32 | if (totalMins >= 60) 33 | { 34 | totalHrs += totalMins / 60; 35 | totalMins %= 60; 36 | } 37 | 38 | return Time(totalHrs, totalMins, totalSecs); 39 | } 40 | 41 | void display() const 42 | { 43 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 44 | } 45 | }; 46 | 47 | int main() 48 | { 49 | int H1, M1, S1, H2, M2, S2; 50 | 51 | cout << "Enter first time: "<< endl << "Hrs: "; 52 | cin >> H1; 53 | cout<<"Mins: "; 54 | cin >> M1; 55 | cout<<"Secs: "; 56 | cin >> S1; 57 | 58 | cout << "Enter second time: "<< endl << "Hrs :"; 59 | cin >> H2; 60 | cout<<"Mins: "; 61 | cin >> M2; 62 | cout<<"Secs: "; 63 | cin >> S2; 64 | 65 | Time time1(H1, M1, S1); 66 | Time time2(H2, M2, S2); 67 | 68 | Time totalTime = time1.sum(time2); 69 | 70 | totalTime.display(); 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/68_Vasu_Dewangan/add_hrs_min_sec.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | class Time 6 | { 7 | private: 8 | int hrs; 9 | int mins; 10 | int secs; 11 | 12 | public: 13 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 14 | 15 | void setTime(int h, int m, int s) 16 | { 17 | hrs = h; 18 | mins = m; 19 | secs = s; 20 | } 21 | 22 | Time sum(const Time &t2) const 23 | { 24 | int totalHrs = hrs + t2.hrs; 25 | int totalMins = mins + t2.mins; 26 | int totalSecs = secs + t2.secs; 27 | 28 | if (totalSecs >= 60) 29 | { 30 | totalMins += totalSecs / 60; 31 | totalSecs %= 60; 32 | } 33 | if (totalMins >= 60) 34 | { 35 | totalHrs += totalMins / 60; 36 | totalMins %= 60; 37 | } 38 | 39 | return Time(totalHrs, totalMins, totalSecs); 40 | } 41 | 42 | void display() const 43 | { 44 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 45 | } 46 | }; 47 | 48 | int main() 49 | { 50 | int H1, M1, S1, H2, M2, S2; 51 | 52 | cout << "Enter first time: "<< endl << "Hrs: "; 53 | cin >> H1; 54 | cout<<"Mins: "; 55 | cin >> M1; 56 | cout<<"Secs: "; 57 | cin >> S1; 58 | 59 | cout << "Enter second time: "<< endl << "Hrs :"; 60 | cin >> H2; 61 | cout<<"Mins: "; 62 | cin >> M2; 63 | cout<<"Secs: "; 64 | cin >> S2; 65 | 66 | Time time1(H1, M1, S1); 67 | Time time2(H2, M2, S2); 68 | 69 | Time totalTime = time1.sum(time2); 70 | 71 | totalTime.display(); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/67_tilak_Verma_#tasveer/add_hrs_min_sec.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | class Time 6 | { 7 | private: 8 | int hrs; 9 | int mins; 10 | int secs; 11 | 12 | public: 13 | Time(int h = 0, int m = 0, int s = 0) : hrs(h), mins(m), secs(s) {} 14 | 15 | void setTime(int h, int m, int s) 16 | { 17 | hrs = h; 18 | mins = m; 19 | secs = s; 20 | } 21 | 22 | Time sum(const Time &t2) const 23 | { 24 | int totalHrs = hrs + t2.hrs; 25 | int totalMins = mins + t2.mins; 26 | int totalSecs = secs + t2.secs; 27 | 28 | if (totalSecs >= 60) 29 | { 30 | totalMins += totalSecs / 60; 31 | totalSecs %= 60; 32 | } 33 | if (totalMins >= 60) 34 | { 35 | totalHrs += totalMins / 60; 36 | totalMins %= 60; 37 | } 38 | 39 | return Time(totalHrs, totalMins, totalSecs); 40 | } 41 | 42 | void display() const 43 | { 44 | cout << "Total time: " << hrs << " hrs, " << mins << " min, " << secs << " sec." << endl; 45 | } 46 | }; 47 | 48 | int main() 49 | { 50 | int H1, M1, S1, H2, M2, S2; 51 | 52 | cout << "Enter first time: "<< endl << "Hrs: "; 53 | cin >> H1; 54 | cout<<"Mins: "; 55 | cin >> M1; 56 | cout<<"Secs: "; 57 | cin >> S1; 58 | 59 | cout << "Enter second time: "<< endl << "Hrs :"; 60 | cin >> H2; 61 | cout<<"Mins: "; 62 | cin >> M2; 63 | cout<<"Secs: "; 64 | cin >> S2; 65 | 66 | Time time1(H1, M1, S1); 67 | Time time2(H2, M2, S2); 68 | 69 | Time totalTime = time1.sum(time2); 70 | 71 | totalTime.display(); 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/02_Abhinav_Anand/Calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 3 | using namespace std; 4 | int dayNumber(int day, int month, int year){ 5 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 6 | year -= month < 3; 7 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 8 | } 9 | string getMonthName(int monthNumber){ 10 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 11 | return (months[monthNumber]); 12 | } 13 | int numberOfDays (int monthNumber, int year){ 14 | switch(monthNumber){ 15 | case 0 : 16 | case 2 : 17 | case 4 : 18 | case 6 : 19 | case 7 : 20 | case 9 : 21 | case 11: return(31); 22 | break; 23 | case 1 : 24 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 25 | return (29); 26 | else 27 | return (28); 28 | break; 29 | case 3 : 30 | case 5 : 31 | case 8 : 32 | case 10 : return(30); 33 | break; 34 | } 35 | } 36 | void printCalendar(int year){ 37 | cout<<"\t\t\t Calendar - Year "< 6){ 50 | k = 0; 51 | cout< 2 | using namespace std; 3 | int dayNumber(int day, int month, int year){ 4 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 5 | year -= month < 3; 6 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 7 | } 8 | string getMonthName(int monthNumber){ 9 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 10 | return (months[monthNumber]); 11 | } 12 | int numberOfDays (int monthNumber, int year){ 13 | switch(monthNumber){ 14 | case 0 : 15 | case 2 : 16 | case 4 : 17 | case 6 : 18 | case 7 : 19 | case 9 : 20 | case 11: return(31); 21 | break; 22 | case 1 : 23 | if (year % 400 == 0 || (year % 4 == 0 && year %100 != 0)) 24 | return (29); 25 | else 26 | return (28); 27 | break; 28 | case 3 : 29 | case 5 : 30 | case 8 : 31 | case 10 : return(30); 32 | break; 33 | } 34 | } 35 | void printCalendar(int year){ 36 | cout<<"\t\t\t Calendar - Year "< 6){ 49 | k = 0; 50 | cout< 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Jai Keshav Sharma AI/Assignment_1/year_calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int dayNumber(int day, int month, int year) { 5 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 6 | year -= month < 3; 7 | return ( year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 8 | } 9 | 10 | string getMonthName(int monthNumber) { 11 | string months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; 12 | return months[monthNumber-1]; // subtract 1 because array index starts from 0 13 | } 14 | 15 | int numberOfDays (int monthNumber, int year) { 16 | if (monthNumber == 2) { 17 | if (year % 400 == 0 || (year % 4 == 0 && year % 100!= 0)) 18 | return 29; 19 | else 20 | return 28; 21 | } 22 | else if (monthNumber == 4 || monthNumber == 6 || monthNumber == 9 || monthNumber == 11) 23 | return 30; 24 | else 25 | return 31; 26 | } 27 | 28 | void printCalendar(int year) { 29 | printf(" Calendar - %d\n\n", year); 30 | int days; 31 | int current = dayNumber (1, 1, year); 32 | for (int i = 0; i < 12; i++) { 33 | days = numberOfDays (i+1, year); // add 1 because monthNumber starts from 1 34 | printf("\n ------------%s-------------\n", getMonthName(i+1).c_str()); // add 1 because monthNumber starts from 1 35 | printf(" Sun Mon Tue Wed Thu Fri Sat\n"); 36 | int k; 37 | for (k = 0; k < current; k++) 38 | printf(" "); 39 | for (int j = 1; j <= days; j++) { 40 | printf("%5d", j); 41 | if (++k > 6) { 42 | k = 0; 43 | printf("\n"); 44 | } 45 | } 46 | if (k) 47 | printf("\n"); 48 | current = k; 49 | } 50 | return; 51 | } 52 | 53 | int main(){ 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Rupali/Calender 2024.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // Function to check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // Function to get the number of days in a month 9 | int daysInMonth(int month, int year) { 10 | if (month == 2) { 11 | return isLeapYear(year) ? 29 : 28; 12 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 13 | return 30; 14 | } else { 15 | return 31; 16 | } 17 | } 18 | // Function to print the calendar of a year 19 | void printCalendar(int year) { 20 | cout << "Calendar of " << year << ":\n\n"; 21 | 22 | // Array to store the names of the months 23 | string months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 24 | 25 | // Loop through each month 26 | for (int month = 0; month < 12; month++) { 27 | cout << "-----------" << months[month] << "-----------\n"; 28 | cout << " Sun Mon Tue Wed Thu Fri Sat\n"; 29 | 30 | // Get the number of days in the current month 31 | int numDays = daysInMonth(month + 1, year); 32 | 33 | // Calculate the starting day of the week 34 | int startDay = (year * 365 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 35 | 36 | // Print leading spaces 37 | for (int i = 0; i < startDay; i++) { 38 | cout << " "; 39 | } 40 | // Print the days of the month 41 | for (int day = 1; day <= numDays; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay > 6) { 45 | startDay = 0; 46 | cout << endl; 47 | } 48 | } 49 | 50 | cout << endl << endl; 51 | } 52 | } 53 | 54 | int main() { 55 | int year = 2024; 56 | printCalendar(year); 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/30_Karan_Singh_Rathore/Calendar.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/33_Kishlay_Kumar/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/44_AI_PrernaSakre/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/71_Vidhirani_Netam/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/24_Hemant_Kumar_Singh_AI/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/42_Prabhat_kumar_singh_AI/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | // To check if the given year is a leap year 5 | bool isLeapYear(int year) { 6 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 7 | } 8 | // To get the number of days in a month 9 | int getDaysInMonth(int month, int year) { 10 | if (month == 2) 11 | { 12 | return isLeapYear(year) ? 29 : 28; 13 | } 14 | else if (month == 4 || month == 6 || month == 9 || month == 11) 15 | { 16 | return 30; 17 | } 18 | else 19 | { 20 | return 31; 21 | } 22 | } 23 | // For printing the calendar of a given year 24 | void printCalendar(int year) { 25 | cout << "Calendar for year " << year << ":" << endl; 26 | cout << "==============================" << endl; 27 | 28 | string months[12] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"}; 29 | 30 | for (int month = 1; month <= 12; month++) { 31 | cout << setw(12) << months[month - 1] << " " << year << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | // Calculate the starting day of the week for the current month 34 | int startDay = (year + (year / 4) - (year / 100) + (year / 400) + ((13 * month + 8) / 5)) % 7; 35 | // Print leading spaces 36 | for (int i = 0; i < startDay; i++) { 37 | cout << " "; 38 | } 39 | // Print days 40 | int daysInMonth = getDaysInMonth(month, year); 41 | for (int day = 1; day <= daysInMonth; day++) { 42 | printf("%4d", day); 43 | startDay++; 44 | if (startDay % 7 == 0 || day == daysInMonth) 45 | { 46 | cout << endl; 47 | } 48 | } 49 | cout << endl << endl; 50 | } 51 | } 52 | 53 | int main() { 54 | int year = 2024; 55 | printCalendar(year); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/06 AI AMAN BANJARE/Calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Calendar { 6 | private: 7 | int year; 8 | 9 | public: 10 | Calendar(int y) : year(y) {} 11 | 12 | bool isLeapYear() { 13 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 14 | } 15 | 16 | int daysInMonth(int month) { 17 | if (month == 2) { 18 | return isLeapYear() ? 29 : 28; 19 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 20 | return 30; 21 | } else { 22 | return 31; 23 | } 24 | } 25 | 26 | void printMonth(int month, int& dayOfWeek) { 27 | int days = daysInMonth(month); 28 | 29 | cout << "---------------------------" << endl; 30 | cout << " " << month << "/" << year << endl; 31 | cout << "---------------------------" << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | 34 | for (int i = 0; i < dayOfWeek; i++) { 35 | cout << " "; 36 | } 37 | 38 | for (int day = 1; day <= days; day++) { 39 | cout << setw(5) << day; 40 | if (++dayOfWeek > 6) { 41 | cout << endl; 42 | dayOfWeek = 0; 43 | } 44 | } 45 | 46 | if (dayOfWeek != 0) { 47 | cout << endl; 48 | } 49 | 50 | cout << endl; 51 | } 52 | 53 | void printCalendar() { 54 | int dayOfWeek = getFirstDayOfYear(); 55 | 56 | for (int month = 1; month <= 12; month++) { 57 | printMonth(month, dayOfWeek); 58 | } 59 | } 60 | 61 | int getFirstDayOfYear() { 62 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 63 | return dayOfWeek; 64 | } 65 | }; 66 | 67 | int main() { 68 | int year; 69 | 70 | cout << "Enter the year: "; 71 | cin >> year; 72 | 73 | Calendar cal(year); 74 | cal.printCalendar(); 75 | 76 | return 0; 77 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/61_AI_ShreyanshPatel/Assignment_1_sol/Calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Calendar { 6 | private: 7 | int year; 8 | 9 | public: 10 | Calendar(int y) : year(y) {} 11 | 12 | bool isLeapYear() { 13 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 14 | } 15 | 16 | int daysInMonth(int month) { 17 | if (month == 2) { 18 | return isLeapYear() ? 29 : 28; 19 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 20 | return 30; 21 | } else { 22 | return 31; 23 | } 24 | } 25 | 26 | void printMonth(int month, int& dayOfWeek) { 27 | int days = daysInMonth(month); 28 | 29 | cout << "---------------------------" << endl; 30 | cout << " " << month << "/" << year << endl; 31 | cout << "---------------------------" << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | 34 | for (int i = 0; i < dayOfWeek; i++) { 35 | cout << " "; 36 | } 37 | 38 | for (int day = 1; day <= days; day++) { 39 | cout << setw(5) << day; 40 | if (++dayOfWeek > 6) { 41 | cout << endl; 42 | dayOfWeek = 0; 43 | } 44 | } 45 | 46 | if (dayOfWeek != 0) { 47 | cout << endl; 48 | } 49 | 50 | cout << endl; 51 | } 52 | 53 | void printCalendar() { 54 | int dayOfWeek = getFirstDayOfYear(); 55 | 56 | for (int month = 1; month <= 12; month++) { 57 | printMonth(month, dayOfWeek); 58 | } 59 | } 60 | 61 | int getFirstDayOfYear() { 62 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 63 | return dayOfWeek; 64 | } 65 | }; 66 | 67 | int main() { 68 | int year; 69 | 70 | cout << "Enter the year: "; 71 | cin >> year; 72 | 73 | Calendar cal(year); 74 | cal.printCalendar(); 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Kanchan_Patel_AI_29/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Function to check if a year is a leap year or not 6 | bool isLeapYear(int year) { 7 | if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) 8 | return true; 9 | else 10 | return false; 11 | } 12 | 13 | // Function to find the day of the week for a given date 14 | int dayOfWeek(int day, int month, int year) { 15 | static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; 16 | year -= month < 3; 17 | return (year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 18 | } 19 | 20 | // Function to print the calendar 21 | void printCalendar(int month, int year) { 22 | // Array containing number of days in each month 23 | int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 24 | 25 | // Adjusting number of days in February for leap years 26 | if (isLeapYear(year)) 27 | daysInMonth[1] = 29; 28 | 29 | // Displaying the header 30 | cout << "---------------------------\n"; 31 | cout << " Calendar - " << month << "/" << year << "\n"; 32 | cout << "---------------------------\n"; 33 | cout << " Sun Mon Tue Wed Thu Fri Sat\n"; 34 | 35 | // Finding the starting day of the week for the given month 36 | int startingDay = dayOfWeek(1, month, year); 37 | 38 | // Printing spaces for days before the starting day 39 | for (int i = 0; i < startingDay; i++) 40 | cout << " "; 41 | 42 | // Printing the days of the month 43 | for (int day = 1; day <= daysInMonth[month - 1]; day++) { 44 | printf("%4d", day); 45 | 46 | // Moving to the next line if it's Saturday 47 | if ((day + startingDay) % 7 == 0 || day == daysInMonth[month - 1]) 48 | cout << endl; 49 | } 50 | } 51 | 52 | int main() { 53 | int month, year; 54 | 55 | // Input month and year from the user 56 | cout << "Enter month (1-12): "; 57 | cin >> month; 58 | cout << "Enter year: "; 59 | cin >> year; 60 | 61 | // Print the calendar 62 | printCalendar(month, year); 63 | 64 | return 0; 65 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Sanjay_singh/Assigment_2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Box { 4 | private: 5 | int width, height, depth; 6 | 7 | public: 8 | // Constructor 9 | Box(int width, int height, int depth) { 10 | this->width = width; 11 | this->height = height; 12 | this->depth = depth; 13 | } 14 | 15 | // Setters 16 | void setWidth(int width) { 17 | this->width = width; 18 | } 19 | 20 | void setHeight(int height) { 21 | this->height = height; 22 | } 23 | 24 | void setDepth(int depth) { 25 | this->depth = depth; 26 | } 27 | 28 | // Getters 29 | int getWidth() const { 30 | return this->width; 31 | } 32 | 33 | int getHeight() const { 34 | return this->height; 35 | } 36 | 37 | int getDepth() const { 38 | return this->depth; 39 | } 40 | 41 | // Method to calculate volume 42 | int calculateVolume() const { 43 | return this->width * this->height * this->depth; 44 | } 45 | }; 46 | 47 | int main() { 48 | // Create a Box object 49 | Box myBox(3, 4, 5); 50 | 51 | // Output initial dimensions 52 | std::cout << "Initial dimensions of the box:" << std::endl; 53 | std::cout << "Width: " << myBox.getWidth() << std::endl; 54 | std::cout << "Height: " << myBox.getHeight() << std::endl; 55 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 56 | 57 | // Calculate and output the volume 58 | std::cout << "Volume: " << myBox.calculateVolume() << std::endl; 59 | 60 | // Modify dimensions using setters 61 | myBox.setWidth(6); 62 | myBox.setHeight(7); 63 | myBox.setDepth(8); 64 | 65 | // Output modified dimensions 66 | std::cout << "\nModified dimensions of the box:" << std::endl; 67 | std::cout << "Width: " << myBox.getWidth() << std::endl; 68 | std::cout << "Height: " << myBox.getHeight() << std::endl; 69 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 70 | 71 | // Calculate and output the new volume 72 | std::cout << "New Volume: " << myBox.calculateVolume() << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/37_AI_Mohan_Sahu/Calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Calendar { 6 | private: 7 | int year; 8 | 9 | public: 10 | Calendar(int y) : year(y) {} 11 | 12 | bool isLeapYear() { 13 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 14 | } 15 | 16 | int daysInMonth(int month) { 17 | if (month == 2) { 18 | return isLeapYear() ? 29 : 28; 19 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 20 | return 30; 21 | } else { 22 | return 31; 23 | } 24 | } 25 | 26 | void printMonth(int month, int& dayOfWeek) { 27 | int days = daysInMonth(month); 28 | 29 | cout << "---------------------------" << endl; 30 | cout << " " << month << "/" << year << endl; 31 | cout << "---------------------------" << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | 34 | for (int i = 0; i < dayOfWeek; i++) { 35 | cout << " "; 36 | } 37 | 38 | for (int day = 1; day <= days; day++) { 39 | cout << setw(5) << day; 40 | if (++dayOfWeek > 6) { 41 | cout << endl; 42 | dayOfWeek = 0; 43 | } 44 | } 45 | 46 | if (dayOfWeek != 0) { 47 | cout << endl; 48 | } 49 | 50 | cout << endl; 51 | } 52 | 53 | void printCalendar() { 54 | int dayOfWeek = getFirstDayOfYear(); 55 | 56 | for (int month = 1; month <= 12; month++) { 57 | printMonth(month, dayOfWeek); 58 | } 59 | } 60 | 61 | int getFirstDayOfYear() { 62 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 63 | return dayOfWeek; 64 | } 65 | }; 66 | 67 | int main() { 68 | int year; 69 | 70 | cout << "Enter the year: "; 71 | cin >> year; 72 | 73 | Calendar cal(year); 74 | cal.printCalendar(); 75 | 76 | return 0; 77 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/56_AI_Sharad_Singh_Thakur/calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Calender{ 5 | public: 6 | int dayNumber(int day, int month, int year) 7 | { 8 | static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1,4, 6, 2, 4 }; 9 | year -= month < 3; 10 | 11 | return ( year + year/4 - year/100 + 12 | year/400 + t[month-1] + day) % 7; 13 | } 14 | string getMonthName(int monthNumber) 15 | { 16 | string months[] = {"January", "February", "March", 17 | "April", "May", "June", 18 | "July", "August", "September", 19 | "October", "November", "December" 20 | }; 21 | 22 | return (months[monthNumber]); 23 | } 24 | int numberOfDays (int monthNumber, int year) 25 | { 26 | int month[]={31,28,31,30,31,30,31,31,30,31,30,31}; 27 | if (monthNumber == 1) 28 | { 29 | if (year % 400 == 0 || 30 | (year % 4 == 0 && year % 100 != 0)) 31 | month[1]=29; 32 | } 33 | return month[monthNumber]; 34 | } 35 | void printCalendar(int year) 36 | { 37 | printf ("\n\n Calendar - %d\n\n", year); 38 | int days; 39 | int current = dayNumber (1, 1, year); 40 | for (int i = 0; i < 12; i++) 41 | { 42 | days = numberOfDays (i, year); 43 | printf("\n ------------%s-%d-------------\n", getMonthName (i).c_str(),year); 44 | printf(" Sun Mon Tue Wed Thu Fri Sat\n"); 45 | int k; 46 | for (k = 0; k < current; k++) 47 | printf(" "); 48 | 49 | for (int j = 1; j <= days; j++) 50 | { 51 | printf("%5d", j); 52 | if (++k > 6) 53 | { 54 | k = 0; 55 | printf("\n"); 56 | } 57 | } 58 | 59 | if (k) 60 | printf("\n"); 61 | 62 | current = k; 63 | } 64 | } 65 | }; 66 | 67 | int main(){ 68 | Calender c1; 69 | c1.printCalendar(100); 70 | return 0; 71 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/Abhay_singh_Ai/This_pointer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Box { 4 | private: 5 | int width, height, depth; 6 | 7 | public: 8 | // Constructor 9 | Box(int width, int height, int depth) { 10 | this->width = width; 11 | this->height = height; 12 | this->depth = depth; 13 | } 14 | 15 | // Setters 16 | void setWidth(int width) { 17 | this->width = width; 18 | } 19 | 20 | void setHeight(int height) { 21 | this->height = height; 22 | } 23 | 24 | void setDepth(int depth) { 25 | this->depth = depth; 26 | } 27 | 28 | // Getters 29 | int getWidth() const { 30 | return this->width; 31 | } 32 | 33 | int getHeight() const { 34 | return this->height; 35 | } 36 | 37 | int getDepth() const { 38 | return this->depth; 39 | } 40 | 41 | // Method to calculate volume 42 | int calculateVolume() const { 43 | return this->width * this->height * this->depth; 44 | } 45 | }; 46 | 47 | int main() { 48 | // Create a Box object 49 | Box myBox(3, 4, 5); 50 | 51 | // Output initial dimensions 52 | std::cout << "Initial dimensions of the box:" << std::endl; 53 | std::cout << "Width: " << myBox.getWidth() << std::endl; 54 | std::cout << "Height: " << myBox.getHeight() << std::endl; 55 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 56 | 57 | // Calculate and output the volume 58 | std::cout << "Volume: " << myBox.calculateVolume() << std::endl; 59 | 60 | // Modify dimensions using setters 61 | myBox.setWidth(6); 62 | myBox.setHeight(7); 63 | myBox.setDepth(8); 64 | 65 | // Output modified dimensions 66 | std::cout << "\nModified dimensions of the box:" << std::endl; 67 | std::cout << "Width: " << myBox.getWidth() << std::endl; 68 | std::cout << "Height: " << myBox.getHeight() << std::endl; 69 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 70 | 71 | // Calculate and output the new volume 72 | std::cout << "New Volume: " << myBox.calculateVolume() << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/31 AI KAVESH SAHU/Calender.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class Calendar { 6 | private: 7 | int year; 8 | 9 | public: 10 | Calendar(int y) : year(y) {} 11 | 12 | bool isLeapYear() { 13 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 14 | } 15 | 16 | int daysInMonth(int month) { 17 | if (month == 2) { 18 | return isLeapYear() ? 29 : 28; 19 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 20 | return 30; 21 | } else { 22 | return 31; 23 | } 24 | } 25 | 26 | void printMonth(int month, int& dayOfWeek) { 27 | int days = daysInMonth(month); 28 | 29 | cout << "---------------------------" << endl; 30 | cout << " " << month << "/" << year << endl; 31 | cout << "---------------------------" << endl; 32 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 33 | 34 | for (int i = 0; i < dayOfWeek; i++) { 35 | cout << " "; 36 | } 37 | 38 | for (int day = 1; day <= days; day++) { 39 | cout << setw(5) << day; 40 | if (++dayOfWeek > 6) { 41 | cout << endl; 42 | dayOfWeek = 0; 43 | } 44 | } 45 | 46 | if (dayOfWeek != 0) { 47 | cout << endl; 48 | } 49 | 50 | cout << endl; 51 | } 52 | 53 | void printCalendar() { 54 | int dayOfWeek = getFirstDayOfYear(); 55 | 56 | for (int month = 1; month <= 12; month++) { 57 | printMonth(month, dayOfWeek); 58 | } 59 | } 60 | 61 | int getFirstDayOfYear() { 62 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 63 | return dayOfWeek; 64 | } 65 | }; 66 | 67 | int main() { 68 | int year; 69 | 70 | cout << "Enter the year: "; 71 | cin >> year; 72 | 73 | Calendar cal(year); 74 | cal.printCalendar(); 75 | 76 | return 0; 77 | } -------------------------------------------------------------------------------- /Assisgnments/Submissions/61_AI_ShreyanshPatel/Assignment_3: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Box { 4 | private: 5 | int width, height, depth; 6 | 7 | public: 8 | // Constructor 9 | Box(int width, int height, int depth) { 10 | this->width = width; 11 | this->height = height; 12 | this->depth = depth; 13 | } 14 | 15 | // Setters 16 | void setWidth(int width) { 17 | this->width = width; 18 | } 19 | 20 | void setHeight(int height) { 21 | this->height = height; 22 | } 23 | 24 | void setDepth(int depth) { 25 | this->depth = depth; 26 | } 27 | 28 | // Getters 29 | int getWidth() const { 30 | return this->width; 31 | } 32 | 33 | int getHeight() const { 34 | return this->height; 35 | } 36 | 37 | int getDepth() const { 38 | return this->depth; 39 | } 40 | 41 | // Method to calculate volume 42 | int calculateVolume() const { 43 | return this->width * this->height * this->depth; 44 | } 45 | }; 46 | 47 | int main() { 48 | // Create a Box object 49 | Box myBox(3, 4, 5); 50 | 51 | // Output initial dimensions 52 | std::cout << "Initial dimensions of the box:" << std::endl; 53 | std::cout << "Width: " << myBox.getWidth() << std::endl; 54 | std::cout << "Height: " << myBox.getHeight() << std::endl; 55 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 56 | 57 | // Calculate and output the volume 58 | std::cout << "Volume: " << myBox.calculateVolume() << std::endl; 59 | 60 | // Modify dimensions using setters 61 | myBox.setWidth(6); 62 | myBox.setHeight(7); 63 | myBox.setDepth(8); 64 | 65 | // Output modified dimensions 66 | std::cout << "\nModified dimensions of the box:" << std::endl; 67 | std::cout << "Width: " << myBox.getWidth() << std::endl; 68 | std::cout << "Height: " << myBox.getHeight() << std::endl; 69 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 70 | 71 | // Calculate and output the new volume 72 | std::cout << "New Volume: " << myBox.calculateVolume() << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/31 AI KAVESH SAHU/Assignment_2_solution: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Box { 4 | private: 5 | int width, height, depth; 6 | 7 | public: 8 | // Constructor 9 | Box(int width, int height, int depth) { 10 | this->width = width; 11 | this->height = height; 12 | this->depth = depth; 13 | } 14 | 15 | // Setters 16 | void setWidth(int width) { 17 | this->width = width; 18 | } 19 | 20 | void setHeight(int height) { 21 | this->height = height; 22 | } 23 | 24 | void setDepth(int depth) { 25 | this->depth = depth; 26 | } 27 | 28 | // Getters 29 | int getWidth() const { 30 | return this->width; 31 | } 32 | 33 | int getHeight() const { 34 | return this->height; 35 | } 36 | 37 | int getDepth() const { 38 | return this->depth; 39 | } 40 | 41 | // Method to calculate volume 42 | int calculateVolume() const { 43 | return this->width * this->height * this->depth; 44 | } 45 | }; 46 | 47 | int main() { 48 | // Create a Box object 49 | Box myBox(3, 4, 5); 50 | 51 | // Output initial dimensions 52 | std::cout << "Initial dimensions of the box:" << std::endl; 53 | std::cout << "Width: " << myBox.getWidth() << std::endl; 54 | std::cout << "Height: " << myBox.getHeight() << std::endl; 55 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 56 | 57 | // Calculate and output the volume 58 | std::cout << "Volume: " << myBox.calculateVolume() << std::endl; 59 | 60 | // Modify dimensions using setters 61 | myBox.setWidth(6); 62 | myBox.setHeight(7); 63 | myBox.setDepth(8); 64 | 65 | // Output modified dimensions 66 | std::cout << "\nModified dimensions of the box:" << std::endl; 67 | std::cout << "Width: " << myBox.getWidth() << std::endl; 68 | std::cout << "Height: " << myBox.getHeight() << std::endl; 69 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 70 | 71 | // Calculate and output the new volume 72 | std::cout << "New Volume: " << myBox.calculateVolume() << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/57_AI_Shivam_Choudhary/Assignment_2_solution: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Box { 4 | private: 5 | int width, height, depth; 6 | 7 | public: 8 | // Constructor 9 | Box(int width, int height, int depth) { 10 | this->width = width; 11 | this->height = height; 12 | this->depth = depth; 13 | } 14 | 15 | // Setters 16 | void setWidth(int width) { 17 | this->width = width; 18 | } 19 | 20 | void setHeight(int height) { 21 | this->height = height; 22 | } 23 | 24 | void setDepth(int depth) { 25 | this->depth = depth; 26 | } 27 | 28 | // Getters 29 | int getWidth() const { 30 | return this->width; 31 | } 32 | 33 | int getHeight() const { 34 | return this->height; 35 | } 36 | 37 | int getDepth() const { 38 | return this->depth; 39 | } 40 | 41 | // Method to calculate volume 42 | int calculateVolume() const { 43 | return this->width * this->height * this->depth; 44 | } 45 | }; 46 | 47 | int main() { 48 | // Create a Box object 49 | Box myBox(3, 4, 5); 50 | 51 | // Output initial dimensions 52 | std::cout << "Initial dimensions of the box:" << std::endl; 53 | std::cout << "Width: " << myBox.getWidth() << std::endl; 54 | std::cout << "Height: " << myBox.getHeight() << std::endl; 55 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 56 | 57 | // Calculate and output the volume 58 | std::cout << "Volume: " << myBox.calculateVolume() << std::endl; 59 | 60 | // Modify dimensions using setters 61 | myBox.setWidth(6); 62 | myBox.setHeight(7); 63 | myBox.setDepth(8); 64 | 65 | // Output modified dimensions 66 | std::cout << "\nModified dimensions of the box:" << std::endl; 67 | std::cout << "Width: " << myBox.getWidth() << std::endl; 68 | std::cout << "Height: " << myBox.getHeight() << std::endl; 69 | std::cout << "Depth: " << myBox.getDepth() << std::endl; 70 | 71 | // Calculate and output the new volume 72 | std::cout << "New Volume: " << myBox.calculateVolume() << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/68_Vasu_Dewangan/calender1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | class Calendar { 7 | private: 8 | int year; 9 | 10 | public: 11 | Calendar(int y) : year(y) {} 12 | 13 | bool isLeapYear() { 14 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 15 | } 16 | 17 | int daysInMonth(int month) { 18 | if (month == 2) { 19 | return isLeapYear() ? 29 : 28; 20 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 21 | return 30; 22 | } else { 23 | return 31; 24 | } 25 | } 26 | 27 | void printMonth(int month, int& dayOfWeek) { 28 | int days = daysInMonth(month); 29 | 30 | cout << "---------------------------" << endl; 31 | cout << " " << month << "/" << year << endl; 32 | cout << "---------------------------" << endl; 33 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 34 | 35 | for (int i = 0; i < dayOfWeek; i++) { 36 | cout << " "; 37 | } 38 | 39 | for (int day = 1; day <= days; day++) { 40 | cout << setw(5) << day; 41 | if (++dayOfWeek > 6) { 42 | cout << endl; 43 | dayOfWeek = 0; 44 | } 45 | } 46 | 47 | if (dayOfWeek != 0) { 48 | cout << endl; 49 | } 50 | 51 | cout << endl; 52 | } 53 | 54 | void printCalendar() { 55 | int dayOfWeek = getFirstDayOfYear(); 56 | 57 | for (int month = 1; month <= 12; month++) { 58 | printMonth(month, dayOfWeek); 59 | } 60 | } 61 | 62 | int getFirstDayOfYear() { 63 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 64 | return dayOfWeek; 65 | } 66 | }; 67 | 68 | int main() { 69 | int year; 70 | 71 | cout << "Enter the year: "; 72 | cin >> year; 73 | 74 | Calendar cal(year); 75 | cal.printCalendar(); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/67_tilak_Verma_#tasveer/calender1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | class Calendar { 7 | private: 8 | int year; 9 | 10 | public: 11 | Calendar(int y) : year(y) {} 12 | 13 | bool isLeapYear() { 14 | return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); 15 | } 16 | 17 | int daysInMonth(int month) { 18 | if (month == 2) { 19 | return isLeapYear() ? 29 : 28; 20 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 21 | return 30; 22 | } else { 23 | return 31; 24 | } 25 | } 26 | 27 | void printMonth(int month, int& dayOfWeek) { 28 | int days = daysInMonth(month); 29 | 30 | cout << "---------------------------" << endl; 31 | cout << " " << month << "/" << year << endl; 32 | cout << "---------------------------" << endl; 33 | cout << " Sun Mon Tue Wed Thu Fri Sat" << endl; 34 | 35 | for (int i = 0; i < dayOfWeek; i++) { 36 | cout << " "; 37 | } 38 | 39 | for (int day = 1; day <= days; day++) { 40 | cout << setw(5) << day; 41 | if (++dayOfWeek > 6) { 42 | cout << endl; 43 | dayOfWeek = 0; 44 | } 45 | } 46 | 47 | if (dayOfWeek != 0) { 48 | cout << endl; 49 | } 50 | 51 | cout << endl; 52 | } 53 | 54 | void printCalendar() { 55 | int dayOfWeek = getFirstDayOfYear(); 56 | 57 | for (int month = 1; month <= 12; month++) { 58 | printMonth(month, dayOfWeek); 59 | } 60 | } 61 | 62 | int getFirstDayOfYear() { 63 | int dayOfWeek = (year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400) % 7; 64 | return dayOfWeek; 65 | } 66 | }; 67 | 68 | int main() { 69 | int year; 70 | 71 | cout << "Enter the year: "; 72 | cin >> year; 73 | 74 | Calendar cal(year); 75 | cal.printCalendar(); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /Assisgnments/Submissions/Suleman_lakra_AI_64/calender_.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Function to check if a year is a leap year or not 6 | bool isLeapYear(int year) { 7 | if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) 8 | return true; 9 | else 10 | return false; 11 | } 12 | 13 | // Function to find the day of the week for a given date 14 | int dayOfWeek(int day, int month, int year) { 15 | static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; 16 | year -= month < 3; 17 | return (year + year/4 - year/100 + year/400 + t[month-1] + day) % 7; 18 | } 19 | 20 | // Function to print the calendar 21 | void printCalendar(int month, int year) { 22 | // Array containing number of days in each month 23 | int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 24 | 25 | // Adjusting number of days in February for leap years 26 | if (isLeapYear(year)) 27 | daysInMonth[1] = 29; 28 | 29 | // Displaying the header 30 | cout << "---------------------------\n"; 31 | cout << " Calendar - " << month << "/" << year << "\n"; 32 | cout << "---------------------------\n"; 33 | cout << " Sun Mon Tue Wed Thu Fri Sat\n"; 34 | 35 | // Finding the starting day of the week for the given month 36 | int startingDay = dayOfWeek(1, month, year); 37 | 38 | // Printing spaces for days before the starting day 39 | for (int i = 0; i < startingDay; i++) 40 | cout << " "; 41 | 42 | // Printing the days of the month 43 | for (int day = 1; day <= daysInMonth[month - 1]; day++) { 44 | printf("%4d", day); 45 | 46 | // Moving to the next line if it's Saturday 47 | if ((day + startingDay) % 7 == 0 || day == daysInMonth[month - 1]) 48 | cout << endl; 49 | } 50 | } 51 | 52 | int main() { 53 | int month, year; 54 | 55 | // Input month and year from the user 56 | cout << "Enter month (1-12): "; 57 | cin >> month; 58 | cout << "Enter year: "; 59 | cin >> year; 60 | 61 | // Print the calendar 62 | printCalendar(month, year); 63 | 64 | return 0; 65 | } 66 | --------------------------------------------------------------------------------