WSQ13: Exam corrections

#TC1017 #WSQ13

Q1:

For this first question we had to print out a kind of rotated pyramid, which I must say I found somewhat complicated because of the nested ifs. All important notes can be found in the source code:

Captura

 


 

Q2:

The superpower one. We had already done this as a quiz, but I didn´t realize my old code wasn´t really working so it took me a while to realize what I was doing wrong. It turned out I had to multiply the result by the base, and I was doing some weird additions. But now it works perfectely.

Captura.PNG


 

Q3:

The fibonacci series was also already done before, it is quite simple.

Captura.PNG


Q4:

This last problem I could not complete, but here is my source code:

#include <iostream>
#include <string>

using namespace std;

int FindPali(string word){
int i, j;
int size = word.size();

/*This cycle should compare all indices to their opposites to chech for symmetry and decide wheter it is a palindrome or not, however it is not doing anything it seems.*/
for (i=0; i<size; i++){
} cout << word[i];
for (j=size; j>0; j–){
} cout << word[j];
if (word[i] == word[j]){
return 1;
}

}

int main(){
string word;
cout << “Please enter the word:” << endl;
getline (cin, word);

if (FindPali(word)==1){
cout << “Palindrome!” << endl;
} else {
cout << “Not a palindrome.”<< endl;
}

}

GitHub link including all questions: https://github.com/diegodamy/Exam2-Q1

CC BY-SA 4.0 WSQ13: Exam corrections by diegodamy is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.