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 7

This function called dot_product receives two lists of numbers (say list1 and
list2). The function returns what is the dot product of the two lists.

For full marks, if the lists are not the same size, then the function should return the
special value of NaN (which represents not a number).

Example. If the input is [2,4,5,6] and [1,2,3,4] the result will be 49 since (2*1)+(4*2)+(5*3)+(6*4) = 49

quiz7-1quiz7-2

Quiz #7

Hello everyone!

I’m glad to tell you that I finished the quiz #7 and as every quiz I want to share it with you.

Here are the instructions:

Create a function called dot_product that receives two lists of numbers (say list1 and
list2). The function returns what is the dot product of the two lists.

For full marks, if the lists are not the same size, then the function should return the
special value of NaN (which represents not a number).

Example. If the input is [2,4,5,6] and [1,2,3,4] the result will be 49 since (2*1)+(4*2)+(5*3)+(6*4) = 49

First of all, let me explain you what is the dot product.

dot

(https://www.mathsisfun.com/algebra/vectors-dot-product.html)

 

So, here is the code of the dot product:

2016-04-24 (1)

dot1

First, I create the function of the dot product wich make the product of the numbers depending in which site of the list the number is.

Then in the main function I ask how many numbers the list is going to have then the user type those numbers.

It is not a difficult code because we only use typical arranges, for loops, accumulators. If you can see my past post and study it, you will be able to make this without problems, remember to practice and do it by your own.

It wasn’t difficult but if you need more info you can go to this site which help me a lot.

Here is the code!

 

Thank you for visit my blog and see you in next post😉

 

Top image: flickr photo by Kaboedel https://flickr.com/photos/nerina/268955686 shared under a Creative Commons (BY-NC) license