[SOLVED] IT1010 - Lab Sheet 5 - Introduction to Programming

30.00 $

Category:

Description

5/5 - (1 vote)

At the end of the class the students should be able to:

  • Use arrays in C programs.

 

Exercise 1:

 

Write  a C program to the following :

  1. Create a single-subscripted array of size 10;
  2. Initialize the array with 25, 32, 45, 2, 13, 9, 6, 10, 17, 4.
  3. Input a search key (number) from the key board and display the location within the array, if the search key is found. If not display “Value not found”.

 

Exercise 2:

 

Write a C program to multiply the content of array A and B and store it in a new array called C.

 

int A[5] = { 10, 20, 30, 40, 50};

int B[5] = { 34, 67, 12, 89, 12};

 

Exercise 3:

 

A company pays its employees a salary between $200 to $1500 .Write a C program (using arrays of counters) that determine how many of the employees earned salaries in each of the following ranges ( assume that each employee’s salary is truncated to an integer amount). The program should stop entering the salaries, when the user input -1 a salary.

 

  1. $200 – $299
  2. $300 – $399
  3. $400 – $499
  4. $500 – $599
  5. $600 – $699
  6. $700 – $799
  7. $800 – $899
  8. $900 – $999
  9. 1000 and above

 

1