#include<iostream>
#include<iomanip>
using namespace std;
bool floatBiggerThanInt()
{
if(sizeof(float)>sizeof(int)) return true;
return false;
}
int main()
{
cout<<"on this computer a float is";
if(!floatBiggerThanInt())cout<<" not ";
cout<<"Bigger than int \n";
return 0;
}
Out put :-
On this computer a float is not bigger than int .
//while running on my computer
The size in bytes of various data types varies from computer to computer. Write a bool...
4. Write a function that returns a value to the main program illustrated below. In the function, the variable passed by the main program needs to be evaluated using a switch statement. The value returned is determined by the case that it matches. (10 points) If value is: return 10 return 20 3 return 30 Anything else, return 0 Main program: #include <iostream> using namespace std; int findValue (int); int main) { Int numb, retvalue cout << "In Enter a...
C++ Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original main(): int main() { double milesPerHour; double minutesTraveled; double hoursTraveled; double milesTraveled; cin >> milesPerHour; cin >> minutesTraveled; hoursTraveled = minutesTraveled / 60.0; milesTraveled = hoursTraveled * milesPerHour; cout << "Miles: " << milesTraveled << endl; return 0; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> using...
#include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code here } void fill(int arr[], int count){ for(int i = 0; i < count; i++){ cout << "Enter number: "; cin >> arr[i]; } } void display(int arr[], int count){ for(int i = 0; i < count; i++){ cout << arr[i] << endl; } } int main() { cout << "How many items: "; int count; cin >> count; int * arr = new...
C++
#include <iostream>
using namespace std;
bool checkinventoryid(int id)
{
return id > 0;
}
bool checkinventoryprice(float price)
{
return price > 0;
}
void endProgram()
{
system("pause");
exit(0);
}
void errorID(string str)
{
cout << "Invalid Id!!! " << str
<< " should be greater than 0" << endl;
}
void errorPrice(string str)
{
cout << "Invalid Price!!!" << str
<< " should be greater than 0" << endl;
}
int inputId()
{...
Program a clean_string function that combines both the convert_lower and remove_punct functionality in one function. In other words, take a string as a parameter and return a clean version of the string that has no punctuation, no spaces and is all lower case. #include <iostream> #include <string> using namespace std; // TODO: Add your clean_string function here int main() { string line; getline(cin, line); while(line != "quit") { cout << clean_string(line) << ": " << line << endl;...
B) draw the runtime stack fall the steps
(a) write the output of the following program. The output must include everything that a computer may produce on its screen, including the prompts, input, output, and their positions. Suppose the input integers are 1 and 2, in this order. (b) Draw the run time stack for every step of execution on the next page. You need to mark the return address(es) yourself. #include <iostream> using namespace std; int a; int b;...
How would I add a line to the main function to sort the people vector by Age using the STL sort function? #include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; struct Person { string name; int age; string favoriteColor; }; bool sortByName(Person &lhs, Person &rhs) { return lhs.name < rhs.name; } bool sortByAge(Person &lhs, Person &rhs) { return lhs.age < rhs.age; } bool sortByColor(Person &lhs, Person &rhs) { return lhs.favoriteColor < rhs.favoriteColor; } int main() { vector<Person>...
(c++) Write a predicate function that checks whether two vectors have the same elements in the same order. Write a predicate function that checks whether two vectors have the same elements in the same order bool equals(vector<int> a, vector<int> b) provided code : #include <iostream> #include <vector> using namespace std; bool equals(vector<int> a, vector<int> b) { // TODO } int main() { // TODO // Print Expected, "Vectors a and b are " (print "equal." if they are. Otherwise, print...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() { char ch; … … ...