Arrays

--Originally published at My awesome Blog!

This is a code of me learning how to use arrays im not sure if im nailing it

#include <iostream>

using namespace std;

int calificaciones [100] {1,1,5,2,8,6,5,3,0,4,10,7,5,1,8,6,5,3,0,1,1,2,5,1,8,6,5,3,2,4,7,1,5,10,8,6,5,7,0,1,9,9,1,9,6,5,9,0,4,9,10,5,1,8,9,5,3,0,4,9,1,5,1,8,6,5,9,0,4,10,10,9,10,8,6,5,3,0,4,10,10,5,10,8,6,5,3,0,4,10,10,5,10,8,6,5,3,0,4};
int n0=0,n1=0,n2=0,n3=0,n4=0,n5=0,n6=0,n7=0,n8=0,n9=0,n10=0;
int valora;
int contador;
int numeroMenosRepetido;
int main(){
//contador numeor 1 para recorrer el array
// casos segundo cuando se repita la calificación
for (int contador = 0; contador <= 99 ; contador++){
valora = calificaciones [contador];
switch (valora){
case 0 :
n0++;
break;
case 1:
n1++;
break;

case 2:
n2++;
break;

case 3:
n3++;
break;

case 4:
n4++;
break;

case 5:

n5++;
break;

case 6:
n6++;
break;

case 7:
n7++;
break;

case 8:
n8++;
break;

case 9:
n9++;
break;

case 10:
n10++;
break;
}

}
//comparar valores obtenidos para sacar el numero que se repite menos DE VERDAD LO SIENTO no se me ocurrio algo mas corto
if (n1<n2 || n1<n3|| n1<n4|| n1<n5|| n1<n6|| n1<n7|| n1<n8|| n1<n9|| n1<n10|| n1<n0) {
cout << “La calificación que menos se repite es : ” << 1 << endl;}
else {
if (n2<n1||n2<n3||n2<n4||n2<n5||n2<n6||n2<n7||n2<n8||n2<n9||n2<n10||n2<n0) {
cout << “La calificación que menos se repite es : ” << 2 << endl;
}
else {
if (n3<n1||n3<n2||n3<n4||n3<n5||n3<n6||n3<n7||n3<n8||n3<n9||n3<n10||n3<n0){
cout << “La calificación que menos se repite es : ” << 3 << endl;
}
else {
if (n4<n1||n4<n2||n4<n3||n4<n5||n4<n6||n4<n7||n4<n8||n4<n9||n4<n10||n4<n0){
cout << “La calificación que menos se repite es : ” << 4 << endl;
}
else{
if (n5<n1||n5<n2||n5<n3||n5<n4||n5<n6||n5<n7||n5<n8||n5<n9||n5<n10||n5<n0){
cout << “La calificación que menos se repite es : ” << 5 << endl;
}

else{
if (n6<n1||n6<n2||n6<n3||n6<n4||n6<n5||n6<n7||n6<n8||n6<n9||n6<n10||n6<n0){
cout << “La calificación que menos se repite es : ” << 6 << endl;
}
else{
if (n7<n1||n7<n2||n7<n3||n7<n5||n7<n4||n7<n6||n7<n8||n7<n9||n7<n10||n7<n0){
cout << “La calificación que menos se repite es : ” << 7 << endl;
}

else {
if (n8<n1||n8<n2||n8<n3||n8<n5||n8<n6||n8<n4||n8<n7||n8<n9||n8<n10||n8<n0){
cout << “La calificación que menos se repite es : ” << 8

Continue reading "Arrays"

Función Coseno

--Originally published at My awesome Blog!

For this code i also use factorial function to get the values for Cos in a function

nice#include <iostream>
#include <cmath>

using namespace std;
float factorial(float);

int main(){
float n, x, s;
float coseno, numerador, fact, cont, denominador, numero;
cout << “Inserta x” << endl;
cin >> x;
cout << “Inserta n” << endl;
cin >> n;

n=n*2;
coseno=0;
s=1;

for(int cont=0; cont<=n;cont=cont+2){
numerador= pow(x,cont);
denominador = factorial(cont);
coseno =(coseno+(s*(numerador/denominador)));
cout<<s<<” “<<numerador<<” / “<<” =”<<coseno << endl;
s = – s;
}

cout << endl;
cout << “La respuesta es:” << coseno;

return 0;
}

float factorial(float numero){
float fact=1, contador;
for(int cont=1; cont<=numero;cont++){
fact = fact*cont;
}
return fact;
}


Funcion Factorial

--Originally published at My awesome Blog!

In the following code ill be using how to use Factorial functions

#include <iostream>
using namespace std;

int main(){
int n, contador;
string respuesta;
cout << “Número Factorial ” << endl;
do
{
cout << “Dame un número positivo ” << endl;
cin >> n;
contador = n;
do
{
contador = contador – 1;
n = n * contador;
}while (contador != 1);
cout << “El factorial es: ” << n << endl;
cout << “¿Quieres probar otro número? ” << endl;
cin >> respuesta;
} while (respuesta == “si”);
cout << “Que tenga un buen día!! ” << endl;
return 0;
}


Final Project Completo

--Originally published at My awesome Blog!

Here i have the final result of my final project. Paco, josue and i worked hard on it and it is finally done

#include <iostream>
#include <fstream>
#include <cmath>
#define pi 3.14159

using namespace std;

char figura;
int HP, LP1, LP2, HC, RC;
float x, y, z;

int main(){
cout << “Que figura quieres (C=Cilindro/P=Prisma): “;
cin >> figura;
if((figura== ‘c’) || (figura== ‘C’)){
cout << “Ingresa la altura en milimetros (No mayor a 1000 mm): ” << endl;
cin >> HC;
cout << “Ingresa el radio en milimetros (No mayor a 1000 mm): ” << endl;
cin >> RC;
ofstream myfile;
myfile.open(“ArchivoCilindroProyecto.txt”);
myfile << “Las coordenadas del cilindro son: ” << endl;
for(z=0; z<=HC; z++){
for (int x=RC; x>=-RC; x–){
y=sqrt(pow(RC,2)-pow(x,2));
myfile << “(” << x << “,” << y << “,” << z << “)” << endl;
}
for (int x=RC-1; x>=-RC+1; x–){
y=sqrt(pow(RC,2)-pow(x,2));
myfile << “(” << x << “,-” << y << “,” << z << “)” << endl;
}
for (int y=RC; y>=-RC; y–){
x=sqrt(pow(RC,2)-pow(y,2));
myfile << “(” << x << “,” << y << “,” << z << “)” << endl;
}
for (int y=RC-1; y>=-RC+1; y–){
x=sqrt(pow(RC,2)-pow(y,2));
myfile << “(-” << x << “,” << y << “,” << z << “)” << endl;
}
}
}else if((figura== ‘p’) || (figura== ‘P’)) {
cout << “Ingresa la altura en milimetros (No mayor a 1000 mm): “;
cin >> HP;
cout << “Ingresa el lado 1 de la base en milimetros (No mayor a 1000 mm): “;
cin >> LP1;
cout << “Ingresa el lado 2 de la base en milimetros (No mayor a 1000 mm): “;
cin >> LP2;
ofstream myfile;
myfile.open(“ArchivoPrismaRectangularProyecto.txt”);
myfile << “Las coordenadas del Prisma rectangular son: ” << endl;
for(int z=0; z<=HP; z++){
for(int

Continue reading "Final Project Completo"

Quiz 7

--Originally published at My awesome Blog!

The next code from my quiz 7 is about arrays

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int dotProduct(int n1, int n2)
{
int resp;
resp = n1 * n2;
return resp;
}

int main()
{
int i, x, add = 0, suma;
cout << “Dame la cantidad de números para las listas ” << endl;
cin >> i;
int lista1[i], lista2[i];
for (x = 0; x < i; x++)
{
cout << “Dame un número para la primer lista ” << endl;
cin >> lista1[x];
}
for (x = 0; x < i; x++)
{
cout << “Dame un número para la segunda lista ” << endl;
cin >> lista2[x];
}
for (x = 0; x < i; x++)
{
suma = dotProduct(lista1[x], lista2[x]);
add += suma;
}
cout << “La respuesta es: ” << add << endl;
}


Quiz 6

--Originally published at My awesome Blog!

What do you think the code below does? answere in the comments

#include <iostream>
#include <stdio.h>
using std::cout;
using std::cin;
using std::endl;

int mcd(int a, int b)
{
int c, d, e;
e = a % b;
do
{
d = b;
b = e;
e = d % b;
} while(e != 0);
return (b);
}

int main(){
int a, b, c, d, e;
cout << “Algoritmo de Euclides ” << endl;
cout << “Introduce un numero ” << endl;
cin >> a;
cout << “Introduce otro numero ” << endl;
cin >> b;
cout << “El M.C.D de los numeros es ” << mcd(a, b) << endl;
return 0;
}


Quiz 5

--Originally published at My awesome Blog!

#include <iostream>
#include <math.h>
using std::cout;
using std::cin;
using std::endl;

int find_threes(int number[], int numNumbers){
int sum = 0;
for(int i = 0; i < numNumbers; i++){
if (number[i] % 3 == 0)
{
sum += number[i];
}
else
{

}
}
return sum;
}

int main(){
const int NUM_NUMBERS=8;
int x[NUM_NUMBERS];
for (int i = 0; i < NUM_NUMBERS; i++){
cout << “Dame un número “;
cin >> x[i];
}
int sum = find_threes(x,8);
cout << “La suma es ” << sum << endl;
}

Here is the code from my quiz 5. Type down the comments what do you think i do


We’ve come a long way from where we began…

--Originally published at Loading…

 

Well, this is my last post about the programming class, but maybe is not my last post in the life, because this is nice, and maybe I could do it later.

I want to thank Ken for everything in this class, it was one of my favorite classes of the semester. I could remember some things I already knew but I think I learn many more in this time. Thank u for your patient, for teaching us some things and correcting us in our learning and especially, thanks for your friendship.

So, this class is a great help if you want to learn, but if you want to pass the course, I recommend that you don’t be with Ken, you just stress about having to post and get points for no reason. This class is about giving more than just the 100%.  

I hope my other classmates have enjoyed the class as much as I did.

Good luck in the rest of the Tec Life.


#WSQ13

--Originally published at OlafGC / Class #TC1017

Hi guys! This is the last post I’ll write, to show you a magic, new and wonderful tool that Ken shared with us. It is called Scilab, and it’s just amazing. It does almost literally everything (except writing your posts for Ken’s class). The link for the video is bellow, and enjoy this, my last post!