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 5

This function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).

quiz5-1

This function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12).

quiz5-2

Quiz #5

Hello everyone,

Today I am going to show you my quiz number five. Lets start!!!

Instructions:

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).
  2. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12)

FIRST CODE:

2016-03-29 (2)

First, we have to know what a palindrome is. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward (https://en.wikipedia.org/wiki/Palindrome). We have to create a function which can detect if the word that we introduce is a palindrome or not.

The code is easy but the new thing is that we need to use two iterators: RBEGIN and REND -for more info you can check this web-. In fact the propose of those vectors is to flip the word then we have to check if the new word is the same as the first word that we introduced.

Another new thing is that we are using STRING and a string is variable made by characters. Here you can get more info abou a string and iterators.

 

SECOND CODE:

2016-03-29 (3)

This code doesn’t

Continue reading “Quiz #5”

Quiz 5

ups, tarde otra vez.

A mi manera, usando listas y pidiéndole al hermoso usuario (suelo ser yo) números, hice que mi programa me pidiera, primero, cuántos números iba a ingresar, para que luego con un for pedirle ese número de veces un número. Después con una función, hice que cada número de los que estaban en la lista creada por el usuario los dividiera entre 3, y si su residuo era ==0, separaba esos números y los sumaba. Finalmente imprimí esa suma.

La otra parte fue ingresar una palabra y luego invertirla, si se invertía y resultaba ser la misma palabra, un palindromo -que se lee igual de izq a derecha que de derecha a izq-, regresaba un true.

blog