Answer:
The C++ code is given below with appropriate comments
Explanation:
//Remove this header file if not using visual studio.
#include "stdafx.h"
//Include the required header files.
#include <iostream>
//Use for maths function.
#include <cmath>
using namespace std;
//Define main function
int main()
{
// Define the variables
double targetValue = 0.3333;
double sensorReading = 0.0;
//Perform the opeartion.
sensorReading = 1.0 / 3.0;
// Get the absolute floating point value and
// Check up to 4 digits.
if (fabs(sensorReading - targetValue) < 1E-4)
{
//Print equal if the values are close enough.
cout << "Equal" << endl;
}
else
{
//Print not equal if the values are not
//close enough.
cout << "Not equal" << endl;
}
system("pause");
//Return the value 0.
return 0;
}
Answer:
#program in Python
#read until user Enter an integer
while True:
#try block to check integer
try:
#read input from user
inp = int(input("Enter an integer: "))
#print input
print("The integer is: ",inp)
break
#if input is not integer
except ValueError:
#print message
print("Wrong: try again.")
Explanation:
In try block, read input from user.If the input is not integer the print a message in except block.Read the input until user enter an integer. When user enter an integer then print the integer and break the loop.
Output:
Enter an integer: acs
Wrong: try again.
Enter an integer: 4a
Wrong: try again.
Enter an integer: 2.2
Wrong: try again.
Enter an integer: 12
The integer is: 12
Answer:
Sarah would best be described as a modernist
Explanation:
A modernist is a person who believe or follow new way of doing things, it could be art work or science and technology. Sarah's believe on science and technology of creating modern way of making progress in problem solving qualifies her to be described as a Modernist.