Sunteți pe pagina 1din 3

Lab-01

Lab Task 1
Write a program to input numbers in the array and calculate the average of
all the numbers entered by the user.

Lab Task 2
Write a program to input 15 integers in the array. Now display amount of
even and amount of odd numbers in the array

Lab Task 3
Write a program to allow the user to store the temperature of the months of
the year. Calculate the average temperature for the entire year and
compare it to the average temperature of the previous year which is
entered by the user. If the average temperature is greater than the previous
year then display “Global warming is present” otherwise display “no global
warming”.
Expected Output

Enter average temperature of previous year: 37.5


Enter temperature for this month:23
Enter temperature for this month:28
Enter temperature for this month:32
.
.
.
The average temperature for this year is :38
Global Warming is present.

Lab Task 4
Write a program to enter the marks of midterm of a class of 15 students.
Find out the average marks obtained by the entire class. Display the
amount of students whose midterm marks were equal or greater than the
average of the class and the amount of students who obtained less than
average of class.
Expected Output

Enter midterm marks of student1: 26


Enter midterm marks of student2: 34
Enter midterm marks of student3: 28
Enter midterm marks of student4: 31
Enter midterm marks of student5: 44
Enter midterm marks of student6: 41
Enter midterm marks of student7: 37
Enter midterm marks of student8: 41
Enter midterm marks of student9: 39
Enter midterm marks of student10: 32
Enter midterm marks of student11: 42
Enter midterm marks of student12: 12
Enter midterm marks of student13: 27
Enter midterm marks of student14: 6
Enter midterm marks of student15: 19

The average marks of the entire class is: 30.6


The number of students obtaining average or more marks are 9
The number of students obtaining below average marks are 6

Lab Task 5
(Linear Search)
15 numbers are entered into an array. The number to be searched is
entered through the by another user. Write a program to find if the number
to be searched is present in the array and if it is present, display the
indexes at which the number is present and the number of times it appears
in the array.
Expected Output

Array = 12, 14, 8,6, 21, 27, 12, 3, 9, 12, 8, 17, 12, 14, 11

Number to be searched:14
14 is present at index: 1
14 is present at index: 13
It is present 2 times in array

Number to be searched:7
Not present in array

Number to be searched:12
12 is present at index: 0
12 is present at index: 6
12 is present at index: 9
12 is present at index: 12
It is present 4 times in array

S-ar putea să vă placă și