#include <iostream>
#include <stdlib>
int main()
{
// Variable declarations.
int product = 1;
for( int i = 0; i <= 7; i++)
{
product *= 2 * i + 1;
}
cout << "Product is: " << product << endl;
system("PAUSE");
return 0;
}
Showing posts with label else if nested if. Show all posts
Showing posts with label else if nested if. Show all posts
Sunday, March 1, 2015
Write a program that calculates and prints the product of the odd integers from 1 to 15
Thursday, February 12, 2015
Thursday, February 5, 2015
Commission Program using nested if
/*
Using the following chart, write an if/else if statement that assigns
.10, .15, or .20 to commission, depending on the value in sales.
Sales Commission Rate
Up to $10,000 10%
$10,000 to $15,000 15%
Over $15,000 20%
*/
#include<iostream>
using namespace std;
void main()
{
int sales =0;
cout<<"Enter Sales = ";
cin>>sales;
if(sales<10000)
{
cout<<"Commission Rate is == 10%"<<endl;
}
else if(sales>=10000||sales<15000)
{
cout<<"Commission Rate is == 15%"<<endl;
}
else
{
cout<<"Commission Rate is == 20"<<endl;
}
}
Using the following chart, write an if/else if statement that assigns
.10, .15, or .20 to commission, depending on the value in sales.
Sales Commission Rate
Up to $10,000 10%
$10,000 to $15,000 15%
Over $15,000 20%
*/
#include<iostream>
using namespace std;
void main()
{
int sales =0;
cout<<"Enter Sales = ";
cin>>sales;
if(sales<10000)
{
cout<<"Commission Rate is == 10%"<<endl;
}
else if(sales>=10000||sales<15000)
{
cout<<"Commission Rate is == 15%"<<endl;
}
else
{
cout<<"Commission Rate is == 20"<<endl;
}
}
write an if/else statement that assigns 0 to x when y is equal to 10. Otherwise it should assign 1 to x.
/*
write an if/else statement that assigns 0 to x when y is equal to 10. Otherwise it should assign 1 to x.
*/
#include<iostream>
using namespace std;
void main()
{
int x=0,y=0;
cout<<"Enter the value of x = ";
cin>>x;
cout<<"Enter the value of y = ";
cin>>y;
if(y==10)
{
x=0;
}
else{
x=1;
}
cout<<"The value of x = "<<x<<endl;
cout<<"The value of y = "<<y<<endl;
}
Read More
write an if/else statement that assigns 0 to x when y is equal to 10. Otherwise it should assign 1 to x.
*/
#include<iostream>
using namespace std;
void main()
{
int x=0,y=0;
cout<<"Enter the value of x = ";
cin>>x;
cout<<"Enter the value of y = ";
cin>>y;
if(y==10)
{
x=0;
}
else{
x=1;
}
cout<<"The value of x = "<<x<<endl;
cout<<"The value of y = "<<y<<endl;
}
Write an if statement that assigns 100 to x when y is equal to 0.
/*
Write an if statement that assigns 100 to x when y is equal to 0.
*/
Code :
#include<iostream>
using namespace std;
void main()
{
int x=0,y=0;
cout<<"Enter the value of x = ";
cin>>x;
cout<<"Enter the value of y = ";
cin>>y;
if(y==0)
{
x=100;
}
cout<<"The value of x = "<<x<<endl;
cout<<"The value of y = "<<y<<endl;
}
Read More
Write an if statement that assigns 100 to x when y is equal to 0.
*/
Code :
#include<iostream>
using namespace std;
void main()
{
int x=0,y=0;
cout<<"Enter the value of x = ";
cin>>x;
cout<<"Enter the value of y = ";
cin>>y;
if(y==0)
{
x=100;
}
cout<<"The value of x = "<<x<<endl;
cout<<"The value of y = "<<y<<endl;
}




