MaxMin.cpp
#include<iostream>
using namespace std;
int main()
{
// variables declaration
int first,second;
// getting two numbers from user
cout<<"Enter first number: ";
cin>>first;
cout<<"Enter second number: ";
cin>>second;
// comparing both numbers using conditional operator
if(first>second)
{
cout<<endl<<"The smaller number is: "<<second<<endl;
cout<<"The larger number is: "<<first<<endl;
}
else
{
cout<<endl<<"The smaller number is: "<<first<<endl;
cout<<"The larger number is: "<<second<<endl;
}
return 0;
}
Output
AreaOfRect.cpp
#include<iostream>
using namespace std;
int main()
{
// variables declaration
int length,width,length2,width2;
//getting length and width for two rectangles
cout<<"Enter length of first rectangle: ";
cin>>length;
cout<<"Enter width of first rectangle: ";
cin>>width;
int area=length*width; // calculating area of first rectangle
cout<<"Enter length of second rectangle: ";
cin>>length2;
cout<<"Enter width of second rectangle: ";
cin>>width2;
int area2=length2*width2; // calculating area of second rectangle
cout<<endl<<"Area of first rectangle is: "<<area<<endl;
cout<<"Area of second rectangle is: "<<area2<<endl;
// checking which area is greater or both are same
if(area>area2)
cout<<"First rectangle has greater area."<<endl;
else
if(area<area2)
cout<<"Second rectangle has greater area."<<endl;
else
cout<<"Both rectangles has same area."<<endl;
return 0;
}
Output
BMI.cpp
#include<iostream>
using namespace std;
int main()
{
//variables declaration
float height,weight;
// getting height and weight from user
cout<<"Enter height: ";
cin>>height;
cout<<"Enter weight: ";
cin>>weight;
// calculating BMI
float bmi=(weight*703)/(height*height);
cout<<endl;
// checking person is optimal weight, under weight or over weight
if(bmi>=18.5 && bmi<=25)
cout<<"The person has optimal weight"<<endl;
else
if(bmi<18.5)
cout<<"The person is underweight"<<endl;
else
if(bmi>25)
cout<<"The person is overweight"<<endl;
cout<<"BMI is "<<bmi<<endl;
return 0;
}
Output
Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user...
Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...
Make a program using Java that asks the user to input an integer "size". That integer makes and prints out an evenly spaced, size by size 2D array (ex: 7 should make an index of 0-6 for col and rows). The array must be filled with random positive integers less than 100. Then, using recursion, find a "peak" and print out its number and location. (A peak is basically a number that is bigger than all of its "neighbors" (above,...