Final exam, question 3…

--Originally published at OlafGC / Class #TC1017

Here we are: the final exam. In this video/tutorial, I’m going to explain how to easily write the function for the third question of our final exam. Here is the code and enjoy the ride!

#include <iostream>
#include <cmath>
using namespace std;

float distancia(float x1, float x2, float y1, float y2)
{
float distancia;
distancia = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
return distancia;
}

int main()
{
float x1, x2, y1, y2;
cout<<“Please insert four numers in order.”<<endl;
cout<<“X1: “;cin>>x1;
cout<<“X2: “;cin>>x2;
cout<<“Y1: “;cin>>y1;
cout<<“Y2: “;cin>>y2;
cout<<“The distance is “<<distancia(x1, x2, y1, y2)<<“.”<<endl;
return 0;
}


Quiz #08 (Most important, final exam question #4)

--Originally published at OlafGC / Class #TC1017

Hello dear friends! A quick tutorial on how to solve the fourth question of the exam. I hope you find this very useful and thanks for watching!

Code:

#include <iostream>
using namespace std;

int fibonacci(int n)
{
int fib=1, pre=0;
for(int accu=0; accu<n; accu++)
{
fib+=pre;
pre=fib-pre;
} return fib;
}

int main()
{
int res,n;
cout<<“Dame número “<<endl;
cin>>n;
res=fibonacci(n);
cout<<“Tu fibonacci es “<<res<<endl;
return 0;
}


Final exam question #1

--Originally published at OlafGC / Class #TC1017

A tutorial video on how to do the “triangle” function for the final exam. Link and code bellow:

#include <iostream>
using namespace std;

int triangle (int size)
{
for(int c1=0; c1<=size; c1++)
{
for (int c2=0; c2<c1; c2++)
{
cout<<“T”;
}
cout<<endl;
}
for (int c1=size-1; c1>0; c1–)
{
for (int c2=c1; c2>0; c2–)
{
cout<<“T”;
}
cout<<endl;
} return 0;
}

int main()
{
int size;
cout<<“Give me the size of your pyramid”<<endl;
cin>>size;
cout<<triangle(size)<<endl;
return 0;
}