- #71
eunhye732
- 11
- 0
if this was a wrong place to put my question, can you tell me where? Thanks
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char myCharacter = 'z';
cout << "The datatype is" << sizeof(int) << " bytes!" << endl;
cout << " the varible has a value of " << myCharacter << endl;
return 0;
}
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
int a = 'a', b = 'b', c = 'c';
cout << "Enter Length of A" << endl;
cin >> a;
cout << "enter length of b" << endl;
cin >> b;
a * a * b * b == c * c
cout << "c =" << c << endl;
system("PAUSE");
return EXIT_SUCCESS
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
double a, b, c;
a = sqrt(b*b+c*c);
cin >> b >> c;
cout << a;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#include <math.h>
using namespace std;
doublemortgage (int c, double b, double a)
{
int i = c;
double j = b;
double k = a;
double l = b/(12 * 100);
double m = c * 12;
double result = k * (l / (1 - pow(1+l, -m)));
return result;
}
int main ()
{
int c;
double b;
double a;
double result;
int x;
cout << "Mortgage Calculation Menu \n";
cout << "1. Enter a Loan Amount \n";
cout << "2. Enter a Loan Rate \n";
cout << "3. Enter a Term in Years \n";
cout << "4. Calculate a Payment \n";
cout << "5. Clear All Input \n";
cout << "9. Quit \n";
cout << "Enter Your Selection: ";
cin >> x;
cout << " \n";
cout << "Enter a Loan Amount: $";
cin >> a;
cout << "Enter a Loan Rate: ";
cin >> b;
cout << "Enter a Term in Years: ";
cin >> c;
cout << "Your Monthly Payment: $"<< mortgage(c, b, a) << endl;
cout << " \n";
cout << "You Entered" << endl;
cout << "Loan Amount: $" << a << endl;
cout << "Loan Rate: " << b << "%" << endl;
cout << "Loan Term: " << c << "years" << endl;
cout << "Monthly Payment: $" << mortgage (c, b, a) << endl;
return0;
}
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int main
{
printf("heuy");
cout<< "hey";
return 0;
}
somethings wrong and i know its the number == setprecision(3) what should i do?#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number;
cout << "Enter a number:";
cin >> number;
cin.ignore();
if (number == setprecision(3) )
{
cout << "Number has 3 digits." << endl;
}
else
{
cout << "It is not a 3 digit number." << endl;
}
cin.get();
return 0;
#include <iostream>
using namespace std;
int main()
{
char character;
cout << "Enter any letter from A to Q: ";
cin>>character;
cin.ignore();
switch (character) {
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
cout << character;
break;
default:
cout << "Letter not in the list. " << endl;
}
cin.get();
return 0;
}
they are using the code pascal which is not explained in dduardo's tutorial#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int pascal(int row, int col)
{
if (row == 0 || col == 0 || row == col + 1)
return 1;
return pascal(row - 1, col - 1) + pascal(row - 1, col);
}
int main(void)
{
int n;
cout << "Enter Row: ";
cin >> n;
cin.ignore();
for (int i = 0; i <= n; ++i) {
for (int j = 0; j < i; ++j)
cout << pascal(i, j) << " ";
cout << endl;
}
cin.get();
return 0;
}
There is, since the requested range of letters is simply a range of ASCII codes.Equilibrium said:by the way i just finished number 2 in assignment 4
please check and is there any other shortcut method ?
Equilibrium said:dduardo's Assaignment # 5
Hey i need help with this one..
kindly explain with detail?
i also found this on another forum
they are using the code pascal which is not explained in dduardo's tutorial
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <cmath>
using namespace std;
main()
{
long double num1, num2, num3;
int number, num4, reset = 1;
do {
cout << "1. Hypotenuse" << endl << "2. Other" << endl;
cin >> number;
switch (number) {
case 1:
cout << "Enter the two sides, each followed by the enter key" << endl;
cin >> num1 >> num2;
num2 = sqrt(num1*num1 + num2*num2);
break;
case 2:
cout << "Please enter the hypotenuse" << endl;
cin >> num1;
cout << "Please enter the other side" << endl;
cin >> num2;
num3 = sqrt(num2*num2 - num1*num1);
cout << num3 << endl;
break;
}
num3 *= 1000;
num1 = num3 - floor(num3);
num1 *= 10;
num1 = floor(num1);
if (num1 >= 5) {
num3 = ceil(num3);
} else {
num3 = floor(num3);
}
num3 /= 1000;
cout << "Thankyou, the desired length is: " << num3 << " to 3d.p." << endl;
cout << "Would you like to reset? (1 to reset)" << endl;
cin >> reset;
} while ( reset == 1);
return 0;
}
if ((num2 > 'a' && num2 < 'q') || (num2 > 'A' && num2 < 'Q')) {
cout << "yes\n";
} else {
cout << "no\n";
}
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
long double factorial (int num)
{
if (num==1)
return 1;
return factorial(num-1)*num; // recursive call
}
int pscl (int n, int r)
{
int out;
long double nf=factorial(n), rf=factorial(r), nrf=factorial(n-r);
long double btm=rf * nrf;
long double tout=nf/btm;
out = (int)tout;
return out;
}
int main(int argc, char *argv[])
{
int rin;
int nin;
int pout;
cout << "input row: ";
cin >> rin;
cout << "input number: ";
cin >> nin;
pout=pscl(nin, rin);
cout << pout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}