Write a C++ Program
Rewrite the following expression using an if….else statement (Assume that all variables are declared properly)
Please make two programs for (a) and (b) individually. The first program must include if..else statement for (a), and the second program must include if..else statement for (b).
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
*/
#include <iostream>
using namespace std;
int main()
{
YOUR CODE
HERE
}
/* // Name: Your Name // ID: Your ID */ #include <iostream> using namespace std; int main() { int x, y; cout << "Enter a value for x: "; cin >> x; if (x < 5) { y = 10; } else { y = 20; } cout << "Value of y is " << y << endl; return 0; }
/* // Name: Your Name // ID: Your ID */ #include <iostream> using namespace std; int main() { int fuel, drive; cout << "Enter a value for fuel: "; cin >> fuel; if (fuel >= 10) { drive = 150; } else { drive = 30; } cout << "Value of drive is " << drive << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.