Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
18 changes: 18 additions & 0 deletions Tutorials/2023-March/Tutorial-03/ex-01-shanelka.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iomanip>
#include <iostream>
using namespace std;

int main() {
float marks[] = {78.4, 90.6, 45.9, 72.2, 54.4};
char names[][20] = {"Ajith", "Wimal", "Kanthi", "Suranji", "Kushmitha"};

cout << setw(5) << "No" << setw(15) << "Name" << setw(10) << "Marks"
<< endl; // print headers

for (int r = 0; r < 5; r++) {
cout << setw(5) << r + 1 << setw(15) << names[r] << setw(10)
<< setiosflags(ios::fixed) << setprecision(2) << marks[r] << endl;
}

return 0;
}
37 changes: 37 additions & 0 deletions Tutorials/2023-March/Tutorial-03/ex-02-shanelka.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <iostream>
using namespace std;

int volume(int height, int width, int length);

int main() {
int box1Height, box1Width, box1Length;
int box2Height, box2Width, box2Length;
int totalVolume, totalSurface;

cout << "Enter Box 1 Height : ";
cin >> box1Height;
cout << "Enter Box 1 Width : ";
cin >> box1Width;
cout << "Enter Box 1 Length : ";
cin >> box1Length;

cout << "Enter Box 2 Height : ";
cin >> box2Height;
cout << "Enter Box 2 Width : ";
cin >> box2Width;
cout << "Enter Box 2 Length : ";
cin >> box2Length;

totalVolume = volume(box1Height, box1Width, box1Length) +
volume(box2Height, box2Width, box2Length);

cout << "Volume of Box is " << totalVolume << endl;

return 0;
}

// Implement the Volume() function here
int volume(int height, int width, int length) {

return height * width * length;
}
48 changes: 48 additions & 0 deletions Tutorials/2023-March/Tutorial-03/ex-03-shanelka.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <iostream>
using namespace std;

// function prototype
int volume(int height, int width, int length);

// create a structure
struct Box {
int Height;
int Width;
int Length;
};

// Do not change the main function
int main() {
// 2. Create a variable called box1 of the Box structure type
Box box1;
// int box1Height, box1Width, box1Length;
// 3. Create a variable called box2 of the Box structure type
Box box2;
// int box2Height, box2Width, box2Length;
int totalVolume;
// 4. Input the height, width, lenght of box1 and box2
cout << "Enter Box 1 Height : ";
cin >> box1.Height;
cout << "Enter Box 1 Width : ";
cin >> box1.Width;
cout << "Enter Box 1 Length : ";
cin >> box1.Length;

cout << "Enter Box 2 Height : ";
cin >> box2.Height;
cout << "Enter Box 2 Width : ";
cin >> box2.Width;
cout << "Enter Box 2 Length : ";
cin >> box2.Length;
// 5. Replace the coding below to pass the Box type structure
totalVolume = volume(box1.Height, box1.Width, box1.Length) +
volume(box2.Height, box2.Width, box2.Length);

cout << "Volume of Box is " << totalVolume << endl;
return 0;
}

// Implement the Volume() function here
int volume(int height, int width, int length) {
return height * width * length;
}
28 changes: 28 additions & 0 deletions Tutorials/2023-March/Tutorial-03/ex-04-shanelka.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

void print(int len, int wth);
void input(int &len, int &wth);

// Do not change the main() function
int main() {
int length = 10, width = 5;

input(length, width);
print(length, width);

return 0;
}

// Do not change the print() function
void print(int len, int wth) {
cout << "Length : " << len << ", Width : " << wth << endl;
}

// Implement the Input Function here
void input(int &len, int &wth) {
cout << "Input length : ";
cin >> len;
cout << "Input width : ";
cin >> wth;
}