$25
Objectives:
Learn to use the Visual Studio 2015 platform. Use arrays and structures in C++.
References :
https://www.tutorialspoint.com/cprogramming/c_arrays.htm https://www.tutorialspoint.com/cprogramming/c_structures.htm Exercise 1:
a) In Visual C++, create a new Win32 Console Application project. Save the project in your Desktop. Name the project as Lab-02-ex1. ( refer Lab-01 for creating a new project in
Visual Studio )
b) Write a C++ program to do the following;
i) Input 10 integers from the keyboard and store them in an array of called numbers. ii) Write a function called searchKey() to send an integer to the function as parameter and search for the number in the number array. If the value is found then return the index of the element and if not found then return -1. Print the index in the main program or a message “Value not found”.
iii) Write a function called findMax() to find the maximum number of this array and print the number in the main program.
Exercise 2:
a) In Visual C++, create a new Win32 Console Application project. Save the project in your Desktop. Name the project as Lab-02-ex2.
b) Write a C++ program to do the following;
i) Create a structure called “Rectangle” and add data members length (int ) and width
(int ).
ii) Write a function called area() to send the length and the width of a rectangle as parameters and return the area.
iii) In the main program, create two variables of the Rectangle structure and store the length and the width of the Yard and the House as shown in the diagram below, and find the Lawn area ( in green ) using the area() function.
House
Yard
1