Surigao State College of Technology: Learning Module No. 8 - Post Test Post Test
Surigao State College of Technology: Learning Module No. 8 - Post Test Post Test
1. Develop a program using array that calculates the sum and average of the
three input values from the keyboard and prints the calculated sum and average.
#include<iostream>
using namespace std;
int main()
{
// declare variables
double 10, 5, 15;
double sum, average;
// display result
cout << "Sum = " << sum << endl;
cout << "Average = " << average << endl;
return 0;
}
2. Develop a program using array that accepts three input values from the
keyboard. Then it should also accept a number to search. This number is to be
searched if it is among the three input values. If it is found, display the message
“Search number is found!!!”, otherwise display “Search numbers is lost!!!.
3. Develop a program using array that searches a number and display the
number of times it occurs on the list of 4 values.
Sample input/output dialogue:
Enter four values:
20 5 2 5
Enter a number: 5
Occurrences: 2
4. Develop a program using array that determines the highest and lowest of
the four input values.
LEARNINGSample
MODULE SURIGAO
input/output dialogue: STATE COLLEGE OF TECHNOLOGY
Enter four values:
20 5 2 5
The highest is : 20
The lowest is: 2
#include <stdio.h>
void main()
{
int arr1[100];
int i, mx, mn, n;
printf("--------------------------------------------------\n
");
scanf("%d",&n);
mx = arr1[0];
mn = arr1[0];
if(arr1[i]<mn)
{
LEARNING MODULE SURIGAO
mn STATE COLLEGE OF TECHNOLOGY
= arr1[i];
}
}
printf("Maximum element is : %d\n", mx);
printf("Minimum element is : %d\n\n", mn);
}
5. Develop a program that would add 2 matrices and display the sum on
screen. Use two-dimensional array in solving this problem.