The switch statement is designed to solve what kind of probl
The switch statement is designed to solve what kind of problem? Can if-else if statement be used to solve the same problem? Write a C++ statement for the following algebraic expression: g = h + 12/4k + a^10 The following program has one or more errors. Fist circle the errors. Then rewrite the corresponding statement(s) to correct the error(s) on the right side. using namespace std; void main() {double num1, num2, sum; Cout num1; Cout num2; num1 + num2 = sum; Cout \"Sum = \"
Solution
Switch case is used to solve menu like program in which there is Menu asking bunch of options to select from
In such cases switch case comes handy.
Yes if-else-if can be used to solve same problem
g = (h+12)/(4*k) + pow(a, 10) //here pow is a in-built function defined in math.h library
#include <iostream> //library must be imported for cout and cin
using namespace std;
int main() //main must return int
{
double num1, num2, sum;
//C++ is a case sensitive language
//cout and cin are all lowercase
cout<<\"Enter a number: \";
cin>>num1;
cout<<\"Enter a number: \";
cin>>num2;
sum = num1+num2;
cout<<\"Sum = \"<<sum;
}
