Skip to content

h #50

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

h #50

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Lab Exercises/Lab-2023-March/02/Lab-02-exe-02.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>

using namespace std;

//Structure for rectangle
struct Rectangle {
int length;
int width;
};

int area(int length, int width); //function prototype

int main()
{
Rectangle house{}; //create variables from Rectangle structure
Rectangle yard{};

cout << "Enter length of house :"; //get user inputs
cin >> house.length;

cout << "Enter width of house :";
cin >> house.width;

cout << "Enter length of yard :";
cin >> yard.length;

cout << "Enter width of yard :";
cin >> yard.width;

cout << "Area of house : " << area(house.length, house.width) << endl;
cout << "Area of yard : " << area(yard.length, yard.width) << endl;
cout << "Area of green color area : " << area(yard.length, yard.width) - area(house.length, house.width) << endl;
}

int area(int length, int width)
{
return length * width;
}
95 changes: 95 additions & 0 deletions Lab Exercises/Lab-2023-March/02/Lab-02-exe01.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Lab-02-exe01.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

int searchKey(int number, int numbers[10]); //function prototype
void findMax(int numbers[10]);

int main() //main function begin
{
int numbers[10]; //array
int i;
int number;

for (i = 0;i < 10;i++)
{
cout << "Enter " << i + 1 << " Number :";
cin >> numbers[i];
}
cout << endl;

cout << "Enter search number :"; //get user input to find integer
cin >> number;

cout << endl;

searchKey(number,numbers); //call the function
findMax(numbers); //call the function max number
return 0;
} //end of the main function

int searchKey(int number, int numbers[10])
{
int i,j;

for (i = 0;i < 10;i++)
{
if (numbers[i] == number)
{
j = 1;
break;
}
else
{
j = 0;
}
}

if (j == 0)
{
cout << "value Not Found" << endl<<endl;
return 0;
}
else
{
cout << "Value Found"<<endl<<endl;
return -1;
}


}


void findMax(int numbers[10])
{
int i, maxn;

maxn = numbers[0];

for (i = 0;i < 10;i++)
{
if (numbers[i] >= maxn)
{
maxn = numbers[i];
}
}

cout <<"Max number is : " << maxn << endl;

return ;
}



// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
59 changes: 0 additions & 59 deletions Lab Exercises/Lab-2023-March/Lab-02/ex-01-shanelka.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions Lab Exercises/Lab-2023-March/Lab-02/ex-02-shanelka.cpp

This file was deleted.