Quiz 1 C++
Quiz 1 C++
#include<iostream>
using namespace std;
int main()
{
for (int i = 0; i < 10; i++)
{
cout<<fun(i)<<” ”;
}
return 0;
}
Output : 0 1 1 2 3 5 …………………………………………
Q1) Take a look at the Code snippet above then answer the following ques ons:
a) Complete the code above so that the func on returns a correct result.
1)
2)
b) From the output of the func on, what does the func on fun() do? Complete the
output of the program
c) If the value of MAX changed to 50, and the itera ons of the loop in main()
changed to 50, the output is……………………….
1. Correct
2. Incorrect
3. Compila on error
4. Run me error
Why?
Q2) Write a func on that return the number of occurrences of a certain element in an
array then write a program that read a string of upper & lower le ers, then compute
the frequency of le ers and print them like the example. For uppercase le ers, treat
them like lowercase ones.
Input: baaaBBzzA
Output: a 4
b 3
z 2