UPDATE: Okay na pala hahaha salamat
C++:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int choice; float num;
cout<<" select something\n";
cout<<"\n";
cout<<"1) Add a value\n";
cout<<"2) Subtract a value\n";
cout<<"3) Multiply a value\n";
cout<<"4) Divide a value\n";
cout<<"5) Calculate the Square Root of a Value\n";
cout<<"6) Calculate a Right Triangle's 3rd side\n";
cout<<"7) Conversion\n";
cout<<" Nth term of an Arithmetic Sequence\n";
cout<<"\n";
cout<<"Drop the number of your choice:\n";
cin>>choice;
int a,x,arr[x],sum=0, dif=0, mul=1, div=1;
while(choice==1){
cout<<"\n";
cout<<"Number of values you want to add: ";
cin>>x;
cout<<"\n";
for(a=0;a<x; a++){
cout<<"Enter your value: ";
cin>>arr[a];}
for(a=0;a<x; a++){
sum=sum+arr[a];}
cout<<"The sum of your "<<x<<" values is: "<<sum;
cout<<"\n";
break;
}
while(choice==2){
cout<<"\nHOW MANY NUMBERS WOULD YOU LIKE TO SUBRACT? :"; cin>>x;
for(a=0;a<x; a++){
cout<<"ENTER A NUMBER: ";
cin>>arr[a];
}
for(a=0;a<x; a++){
dif=-(arr[a]+dif);
}
cout<<"THE DIFFERENCE OF THE "<<x<<" NUMBERS IS: "<<dif;
break;
}
while(choice==3){
cout<<"\n";
cout<<"Number of values you want to multiply: ";
cin>>x;
cout<<"\n";
for(a=0;a<x; a++){
cout<<"Enter your value: ";
cin>>arr[a];}
for(a=0;a<x; a++){
mul=mul*arr[a];}
cout<<"The product of your "<<x<<" values is: "<<mul;
cout<<"\n";
break;
}
while(choice==4){
cout<<"\nHOW MANY NUMBERS WOULD YOU LIKE TO DIVIDE? :"; cin>>x;
for(a=0;a<x; a++){
cout<<"ENTER A NUMBER: ";
cin>>arr[a];
}
for(a=0;a<x; a++){
div=arr[a]/div;
}
cout<<"THE PRODUCT OF THE "<<x<<" NUMBERS IS: "<<div;
break;
}
while(choice==5){
cout<<"\n";
cout<<"Enter the number you want to get the Square Root of: ";
cin>>x;
cout<<"The Square Root of "<<x<<" is "<<sqrt(x);
break;
}
while(choice==6){
char choice; float S1, S2, S3;
cout<<"\n";
cout<<"Select the 3rd side of Right Triangle you need (Enter your choice in a CAPITAL LETTER)\n";
cout<<"\n";
cout<<"A)Opposite (Side 1)\n";
cout<<"B)Adjacent (Side 2)\n";
cout<<"C)Hypotenuse (Side 3)\n";
cout<<"\n";
cin>>choice;
cout<<"\n";
switch(choice){
case('A'):
cout<<"Enter value for Adjacent Side: ";
cin>>S2;
cout<<"Enter value for the Hypotenuse: ";
cin>>S3;
cout<<"\n";
cout<<"The value of the Opposite Side is: "<<sqrt((S3*S3)-(S2*S2));
break;
case('B'):
cout<<"Enter value for Opposite Side: ";
cin>>S1;
cout<<"Enter value for the Hypotenuse: ";
cin>>S3;
cout<<"\n";
cout<<"The value of the Adjacent Side is: "<<sqrt((S3*S3)-(S1*S1));
break;
case('C'):
cout<<"Enter value for Opposite Side: ";
cin>>S1;
cout<<"Enter value for Adjacent Side: ";
cin>>S2;
cout<<"\n";
cout<<"The value of the Hypotenuse is: "<<sqrt((S1*S1)+(S2*S2));
break;
default:
cout<<"Invalid Entry";
break;
}
}
while(choice==7){
cout<<"\n1)CENTIMETER TO INCH 2)OUNCE TO LITER\n";
cout<<"3)KILOGRAM TO POUND 4)CELSIUS TO FAHRENHEIT\n\n";
cin>>choice;
switch(choice){
case(1):
cout<<"\nCENTIMETERS: "; cin>>num;
cout<<"\n"<<num<<"cm = "<<num/2.54<<"in";
break;
case(2):
cout<<"\nOUNCE/S: "; cin>>num;
cout<<"\n"<<num<<"oz = "<<num/33.814<<" Liter/s";
break;
case(3):
cout<<"\nKILOGRAM/S: "; cin>>num;
cout<<"\n"<<num<<"kg = "<<num*2.20462<<"lb";
break;
case(4):
cout<<"\nCELSIUS: "; cin>>num;
cout<<"\n"<<num<<"°C = "<<((num*1.8)+32)<<"°F";
break;
default:
cout<<"Invalid Entry";
break;
}
}
while(choice==8){
}
}
}
Last edited: