0% found this document useful (0 votes)
12 views3 pages

Quiz 1 C++

The document is a quiz for a C++ programming class. It includes a code snippet of a Fibonacci number function and questions about completing the code, describing the function, and analyzing how changing values would affect the output.

Uploaded by

Mohamed Karam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Quiz 1 C++

The document is a quiz for a C++ programming class. It includes a code snippet of a Fibonacci number function and questions about completing the code, describing the function, and analyzing how changing values would affect the output.

Uploaded by

Mohamed Karam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Cairo University CMP 1171

Faculty of Engineering C++ Programming & Data


Electronics & Communication Structures
Department 1 Year 2022-2023
Quiz 1
Time: 25 min

Name: Sec. BN:

#include<iostream>
using namespace std;

const int MAX = 20;


int fun(int n)
{
sta c int memory[MAX] = {0};
memory[0] = 0;
memory[1] = 1;
if(memory[n] == 0 & ……………(1)…………..)
{
………………………(2)………………………
return memory[n];
}
else
return memory[n];
}

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

You might also like