Discussion – Loops and Arrays Write pseudocode for a program that will record weather-related data for any month or months. Input could be month name(s) for loop inputs could be: High and low temperatures Precipitation iii. Humidity.
Answer:
Pseudocode.
void fun()
{
Int m= number of Months; // number of months input
Input m;
Initialize Array1[m] , Array2[m]
Loop (Initialize i=0 to i<m)
Input Month Name;
Store Array1[i] as Month Name;
Loop(Initialize j=0 to j<m) //input humidity, precipitation or temperature serial wise as name of Month entered
Input Temperature;
Input Precipitation:
Input Humidity;
Store Array2[j] as Temperature, Precipitation, Humidity;
Loop (Initialize k=0 to k<m)
Output Array1[k] , Array2[k]; //will print the Month Name with Temprature, Precipitaion, Humidity
return 0;
}
Summary:
- Basically, pseudocode is a high-level algorithm definition that can be applied in any programming language.
- The for loop takes the group elements and executes for each element within the loop.
- A plant that makes iron profiles has a lot of “n” pieces. Create a program that asks you to enter the quantity of pieces to be processed by keyboard and then enter the length of each profile, knowing that the pieces whose length is in the range of 1.20 and 1.30 are suitable. Print on the screen the number of suitable pieces in the batch.
Answer:
The above problem is solved with Python language.
Code:
def batches ():
print (“Enter the number of pieces: “)
n = Int (input ())
arr = list ()
for i in range (n):
j = float (input(“Enter the element: “))
arr.append (j)
c = 0
for i in range (n):
If (arr[i] > 1.20 and arr [i] < 1.30):
c = c+1;
print (“The number of suitable pieces in the batch are: “, c)
batches()