Quiz

Quiz 1

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
float r, h, v;
cout<<“Dame el radio: “;
cin>>r;
cout<<“Dame la altura: “;
cin>>h;
v=3.1416*r*r*h;
cout<<“el resultado es “<<v;
getch();
return 0;
}

#include <iostream>
#include <conio.h>
#include <cstring>
using namespace std;
int main()
{
int resul2, num1, num2,resul3;
float resul1;
cout<<“Dame un numero: “;
cin>>num1;
cout<<“Dame otro numero: “;
cin>>num2;
resul3=num1*num2;
resul2=(int)num1/num2;
resul1=num1/num2;
cout <<“nEl resultado de multiplicarlos es “<<resul3;
cout <<“nTu resultado de una division entera es “<<resul2;
cout <<“nEl resultado de una division con decimales es “<<resul1;
}

#include <iostream>
#include <conio.h>
#include <cstring>
using namespace std;
int main()
{
int resul2, resul1, resul3, resul4;
float num1, num2;
cout<<“Dame un numero: “;
cin>>num1;
cout<<“Dame otro numero: “;
cin>>num2;
resul1=num1*num2;
resul2=num1/num2;
resul3=num1+num2;
resul4=num1-num2;
cout <<“nEl resultado de multiplicarlos es “<<resul1;
cout <<“nEl resultado de una division es “<<resul2;
cout <<“nEl resultado de una suma es “<<resul3;
cout <<“nEl resultado de resta es “<<resul4;
}

Quiz 2

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int num, i;
i=1;
cout<<“nCuantos estrellas quieres: “;
cin>>num;
do
{
i++;
cout <<“*”;
} while(i<=num);
getchar();
return 0;
}

#include<iostream>
#include<math.h>
long superpower(long a,long b)
{
using namespace std;
long res;
res=pow(a,b);
cout << “El resultado de “<<a<<“^”<<b<<“=”<<res<<endl;
}
int main(){
using namespace std;
long base,exp;
cout << “Dame la base del numero a elevar”<<endl;
cin>>base;
cout << “Dame el exponente del numero a elevar”<<endl;
cin>>exp;
superpower(base,exp);
system(“pause”);
return 0;
}

Quiz 3

#include <iostream>
#include <cmath>
#include <math.h>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main()
{
int x1,x2,y1,y2;
double x,y,result;
cout <<“nDame la cooordenada x de el eje x del primer punto”<<endl;
cin>>x1;
cout <<“nDame la cooordenada x de el eje y del primer punto”<<endl;
cin>>y1;
cout

Continue reading “Quiz”

Quiz #4

Hello everyone,

Today I’m going to share with you my quiz #4.

Instructions: 

The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828,[1] and is the limit of (1 + 1/n)n as n approaches infinity, an expression that arises in the study of compound interest. It can also be calculated as the sum of the infinite series.

Create a function called euler_calc with a single parameter precision. The value of precision is used to determine when to stop calculating. Your calculation will stop when the two consecutive values estimating e differ by less than precision (remember to use absolute value when calculating the difference between two values here).

 

And here is my code:

2016-03-21 (3)2016-03-21 (4)

The Euler number is very important in the math area and we can calculate it with this formula:

e =  displaystylesumlimits_{n = 0}^{ infty} dfrac{1}{n!} = 1 + frac{1}{1} + frac{1}{1cdot 2} + frac{1}{1cdot 2cdot 3} + cdots

Image link

All the stuff is the same as the last posts but the new thing here is that we are including a new library for us.

With the <iomanip> library  we can use SETPRECISION. It can help us to give an answer exactly with the precision that the user wants and that is what I made with the code. An example of SETPRECISION is:

// setprecision example
#include <iostream>
#include <iomanip>
using namespace std;

int main () {
  double f =3.14159;
  cout << setprecision (5) << f << endl;
  cout << setprecision (9) << f << endl;
  return 0;
}

The execution of this example shall display:
  3.1416
3.14159

Example Link

It is a great tool for the one that really are especial with the specific results in math. Practice and it’ll become easier for you.

This other web site help me to know more about euler number.

See you

Continue reading “Quiz #4”