Hello,
Well this time share with you some of the documents that were part of my exam for the second partial…
I had to do 4 programs:
The first one will print a triangle as big as the number you first entered,
#include <iostream>
using namespace std;
int main(){
int superpower=1, a, b, c=0;
cout <<“This program will ask you for 2 numbers and determine the first number raised to the power of the second number”<<endl;
cout <<” enter the first number”<< endl;
cin>>a;
cout <<“enter the second number”<<endl;
cin>>b;
superpower=superpower*a;
c=c+1;
while(c<b){
a=a*superpower;
c=c+1;
}
cout<<a<<endl;
}
The second program asks you for 2 numbers and multiplies the first one times the second one:
#include <iostream>
using namespace std;
int main(){
int superpower=1, a, b, c=0;
cout <<“This program will ask you for 2 numbers and determine the first number raised to the power of the second number”<<endl;
cout <<” enter the first number”<< endl;
cin>>a;
cout <<“enter the second number”<<endl;
cin>>b;
superpower=superpower*a;
c=c+1;
while(c<b){
a=a*superpower;
c=c+1;
}
cout<<a<<endl;
}
The third program will give you the fibonacci number that corresponds to the number you entered:
#include <iostream>
using namespace std;
int fibonacci(int n){
if(n==0){
return 0;
}
if(n==1){
return 1;
}
return (fibonacci(n-1)+fibonacci(n-2));
}
int main(){
cout<< fibonacci(6)<<endl;
return 0;
}
And the four one tells you if the word is a palindrome or not :
#include <iostream>
#include <string>
using namespace std;
bool palindrome(string cadena, int size){
for(i=0, i< (size/2), i++){
return True;
}
return False;
}
int main(){
string cadena;
int size;
cout<< “This program will determine if the word you type is a palindrome”<<endl;
cout<<“please enter a word”<<endl;
getline(cin, cadena);
}
This was a really good exam even though it was easy but at the moment I didn’t though that at all, after the
was when everything came too me so clear haha
Regards
-Mute Songs-
Wsq13 by edithsantoscom is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.