Answer:
#include <bits/stdc++.h>
using namespace std;
// driver function
int main()
{
// variables
const double g = 9.8;
int sec;
double height;
int t = 0;
double d = 0;
bool flag = false;
// ask to enter time
cout << "Please enter the time of fall(in seconds):";
// read time
cin >> sec;
//ask to enter height
cout << "Please enter the height (in meters):";
//read height
cin >> height;
cout << '\n'
<< "Time(seconds) Distance(meters)\n"
"********************************\n";
// calculate height after each seconds
while ( t <= sec) {
cout << setw(23) << left << t
<< setw(24) << left << d << '\n';
// if input height is less
if ( d > height ) {
flag = true;
}
// increament the time
t += 1;
// find distance
d = 0.5 * g * (t) * (t);
}
cout << '\n';
// if input height is less then print the Warning
if ( flag ) {
cout << "Warning - Bad Data: The distance fallen exceeds the height"
" of the bridge.\n";
}
return 0;
}
Explanation:
Read the time in seconds from user and assign it to "sec" then read height and assign it to "height".After this find the distance after each second.If the input height is less than the distance at any second, it will print a Warning message. otherwise it will print the distance after each second.
Output:
Please enter the time of fall(in seconds):11
Please enter the height (in meters):1111
Time(seconds) Distance(meters)
********************************
0 0
1 4.9
2 19.6
3 44.1
4 78.4
5 122.5
6 176.4
7 240.1
8 313.6
9 396.9
10 490
11 592.9
Answer:
With the analysis of the case, we can infer that regarding the model or algorithm of the work set, we want to reduce page faults in each individual process, guaranteeing that the set of pages are included before executing the process.
There are things that should not change, such as the set of pages used in the process or the working set as they are called, they could only change if a program moves to a different phase of execution. In this way the most suitable and profitable approach is proposed for the use of time in the processor, by avoiding bringing oagines from the hard disk and instead of this the process is executed, because otherwise it would take a long time what was observed in decreased performance.
Regarding what was mentioned in the question, it follows that 2 extremes lead to a problematic behavior, to define the first as a page fault and the second refers to a small number of processes executed.
Answer:
#include <iostream>
using namespace std;
void askCat(int &cateto1, int &cateto2);
int AreaRett(int cateto1, int cateto2, int &area);
void stampaRisultato(int area);
int main()
{
int cateto1, cateto2, area;
askCat(cateto1, cateto2);
area = AreaRett(cateto1, cateto2,area);
stampaRisultato(area);
}
void askCat(int &cateto1, int &cateto2)
{
cout << "Inserisci lunghezza cateto1: ";
cin >> cateto1;
cout << "Inserisci lunghezza cateto2: ";
cin >> cateto2;
}
int AreaRett(int cateto1, int cateto2, int &area)
{
area = (cateto1*cateto2)/2;
return area;
}
void stampaRisultato(int area)
{
cout << "L'area del triangolo rettangolo e': " << area << endl;
}
vowels = "aeiou"
txt = input("Enter a string: ")
print("The vowels are ",end="")
for x in txt:
if x.lower() in vowels:
print(x, end="")
I hope this helps!
Answer:
It helps to put the code in to your working memory and you will have a greater ability to problem solve.
Explanation:
If your just a beginner, then writing the code out your self will help you learn what each line means. Also, you will see the effects that each line has. Of course, this is really dependent on how much code you've written before and how much code your dealing with.