IT1050 Lab 2 Solved

30.00 $

Category:

Description

5/5 - (1 vote)

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:

BSc (Hons) in Information Technology Year 1

  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 )
  2. 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:

  1. a)  In Visual C++, create a new Win32 Console Application project. Save the project in your Desktop. Name the project as Lab-02-ex2.
  2. 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.

Yard

House

1

  • Lab-02-x9cdv8.zip