Elon Musk: Biography of a Billionaire Visionary

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

REPUBLIQUE DU CAMEROUN REPUBLIC OF CAMEROON

Paix-Travail-Patrie Peace-Work-Fatherland
…………... …………...
MINISTERE DE L’ENSEIGNEMENT SUPERIEUR MINISTRY OF HIGHER EDUCATION
..………... …………...
COMMISSION NATIONALE D’ORGANISATION NATIONAL COMMISSION FOR THE ORGANISATION OF
DES EXAMENS THE EXAMS
……………. …………...

NATIONAL EXAM OF HIGHER NATIONAL DIPLOMA – 2024 Session

Specialty/Option: SWE
Duration: 6 hours
Paper: Case Study
Coef: 12
MARKING GUIDE
Instructions:
This paper contains four (04) sections. All sections are compulsory. Answer all questions neatly
and clearly, label your work.

SECTION A: ALGORITHM AND PROGRAMMING. (50marks)

I. DATA STRUCTURES AND ALGORITHMS (10 MARKS)

1.

First, we shall determine half of the array by using this formula −

mid = low + (high - low) / 2


Here it is, 0 + (9 - 0 ) / 2 = 4 (integer value of 4.5). So, 4 is the mid of the array.

Now we compare the value stored at location 4, with the value being searched, i.e. 31. We find that
the value at location 4 is 27, which is not a match. As the value is greater than 27 and we have a
sorted array, so we also know that the target value must be in the upper portion of the array.

We change our low to mid + 1 and find the new mid value again.

low = mid + 1
mid = low + (high - low) / 2
Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.

P a g e 1 | 10
The value stored at location 7 is not a match, rather it is more than what we +are looking for. So, the
value must be in the lower part from this location.

Hence, we calculate the mid again. This time it is 5.

We compare the value stored at location 5 with our target value. We find that it is a match.

We conclude that the target value 31 is stored at location 5.

II. EVENT PROGRAMMING (10 MARKS)


1. console.writeline() prints the results on the screen and causes the cursor to move to the next line
while console.write() prints the output to the screen and causes the cursor to remain on the same
line.
2. console.readkey() prevents the console from disappearing almost immediately when printing the
results.
3.

Private Sub BtnCal_Click(sender As Object, e As EventArgs) Handles BtnCal.Click


Dim YourName As String
Dim Num1 As Integer
Dim Num2 As Single
Dim Sum As Integer
Dim RunDate As Date
YourName = TxtName.Text
Num1 = Val(TxtNum1.Text)
Num2 = Val(TxtNum2.Text)
Sum = Num1 + Num2
LblSum.Text = Str(Sum)
RunDate = Format(Now, "General Date")
LblDate.Text = RunDate
End Sub
P a g e 2 | 10
III. STRUCTURED PROGRAMMING (15 MARKS)

1. What are some of the advantages of using functions in c programs? (3marks)


There are the following advantages of C functions.
o By using functions, we can avoid rewriting same logic/code again and again in a program.
o We can call C functions any number of times in a program and from any place in a program.
o We can track a large C program easily when it is divided into multiple functions.
o Reusability is the main achievement of C functions.

2. Differentiate between syntax and logical error in programming (2 marks)


ANSWER:
Syntax errors: these are errors reported by the translators when the rules of a the programming
language are not obeyed
Logical errors: these are errors due to bad reasoning by the programmer

3. Decimal to Binary conversion (5marks)

Write a C++ program that converts a decimal (base 10) number to binary (base 2). Read the decimal
number from the user as an integer and then use the division algorithm shown below to perform the
conversion.When the algorithm completes, result contains the binary representation of the number.
Display the result, along with an appropriate message.

Let result be an empty string


Let q represent the number to convert
repeat
Set r equal to the remainder when q is divided by 2
Convert r to a string and add it to the beginning of result
Divide q by 2, discarding any remainder, and store the result back into q
until q is 0
SOLUTION :
// C++ program to convert a decimal
// number to binary number

#include <iostream>
using namespace std;

// function to convert decimal to binary


void decToBinary(int n)
{
// array to store binary number
int binaryNum[32];

// counter for binary array


int i = 0;
while (n > 0) {

// storing remainder in binary array


binaryNum[i] = n % 2;
n = n / 2;
i++;
}

P a g e 3 | 10
// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << binaryNum[j];
}
// Driver program to test above function
int main()
{
int num ;
cout<< "Enter a decimal number to convert :" ;
cin >> num ;
cout << " the answer is: ";
decToBinary(num);
return 0;
}
1. Is a Number Prime? (5 marks)
A prime number is an integer greater than 1 that is only divisible by one and itself. Write a simple
C++ program that will prompt the user to input a number and determine whether it is prime or not.
SOLUTION
#include <iostream>
using namespace std;
int main()
{
int n, i, m=0, flag=0;
cout << "Enter the Number to check Prime: ";
cin >> n;
m=n/2;
for(i = 2; i <= m; i++)
{
if(n % i == 0)
{
cout<<"Number is not Prime."<<endl;
flag=1;
break;
}
}
if (flag==0)
cout << "Number is Prime."<<endl;
return 0;
}
IV. OBJECT ORIENTED PROGRAMMING (15 MARKS)
1. Differentiate between a private and a public data member. (2 marks)

ANSWER:
A data member declared as public is directly accessible to any class or function of the program
where as those declared as private cannot be accessed directly.
2. What is a dot (.) operator in C++? (2marks)
ANSWER:
A dot operator is a member access operator used to access or reference individual member of a
structure, union or class.
P a g e 4 | 10
3. From what does an abstract class differs from a concrete class? (2marks)
ANSWER:
An abstract class is a partially defined class that cannot be instantiated. In an abstract class, not all
methods are completely implemented. Whereas concrete Classes are regular classes, where all
methods are completely implemented.

4. Define the following terms or expressions related to object oriented programming:


Encapsulation, polymorphism. (2 marks)
ANSWER:
Encapsulation: It is the process of binding both attributes (data) and methods (operations) together
within a class. The wrapping up of data and functions (operations) into a single unit is known as
encapsulation.
Polymorphism: It is an object-oriented programming concept that refers to the ability of a variable,
function or object to take on multiple forms.

5. Modularity is one important concept in Object Oriented technology. Give some of it benefits
(2 marks)

ANSWER:
Modularity is the physical and logical decomposition of large and complex things into smaller and
manageable components that achieve the software engineering goals. It is about breaking up a large
chunk of a system into small and manageable subsystems. Some of it advantages are the following:

• Improved software maintainability


• Faster development
• Improved software-development productivity

6. Write a probram with a mother class animal. Inside it, define two data members (name and
age) and a member function set_value(). Then create two base classes Zebra and Dolphin,
which write or display a message telling the age, the name and giving some extra information
(e.g. place of origin). Illustrate the use of these classes in the main() function by creating
some instances from them.
(5marks)

SOLUTION :
#include <iostream>
#include <cstring>
using namespace std;

class Animal
{

P a g e 5 | 10
protected:
int age;char name[10];
public:
void set_data (int a, char b[10])
{
age = a;
strcpy(b,name);
}
};

class Zebra:public Animal


{
public:
void message_zebra()
{cout<< "The zebra named "<< name<<" is "<< age << "years old. The
zebra comes from Africa. \n";}
};

class Dolphin: public Animal


{
public:
void message_dolphin()
{cout<< "The dolphin named "<< name<< " is "<<age << "years old.
The dolphin comes from New Zeland.\n";}
};
int main ()
{
Zebra zeb;
Dolphin dol;
char n1[10]="Ana";
char n2[10]="Jin";

zeb.set_data (5,n1);
dol.set_data (2,n2);

zeb.message_zebra() ;
dol.message_dolphin() ;
return 0;
}

SECTION B: DATABASE (20marks)

1. a) What is meant by normalization in database? (1mark)


ans: Normalization is a formal framework for analyzing given relation schemas based on
their FDs and primary keys to achieve desirable properties of minimizing redundancy and
anomalies
b) State and explain the different normal form (3marks)

P a g e 6 | 10
- 1NF: Defined to disallow multivalued and/or composite attributes or their
combinations
- 2NF: A relation schema is in second normal form (2NF) if it is in 1NF and there
are no functional dependencies with a proper subset of a candidate key on the left
hand side.
- 3NF: This normal form is based on the concept of transitive dependency.
- BCNF
c) For the figure below state weather it is normalize or not. If not, state the normal form and
normalize the table. (3marks)

Ans: it is not normalize. Because the attribute DLOCATION contain multivalue. It is not in
1NF. It can be normalized by breaking the multivalued attributes (there are other methods)
as shown below.

d) What is functional dependency (1mark)

Ans: Functional dependency (FD) is a restriction on combination of tuples that can


appear in a relation. X -> A (X functionally determines A)
2. Give examples of DDL, DCL and DML as used in SQL (2marks)
Ans: DDL: CREATE, DROP, ALTER, RENAME DCL: GRANT, REVOKE
DML: SELECT, INSERT, UPDATE, DELETE
3. The questions below concerns the table below
a) What is the cardinality and degree of the relation (2marks)
Ans: cardinality: 4 degree: 3
b) List the attributes and choose a suitable primary key attribute for the relation (1mark)
P a g e 7 | 10
Ans: attributes: StudentID, Name, gpa. Suitable primary key is StudentID
c) Write an SQL command to create the table below. The table name should be student_info
(2mark)
CREATE table student_info(
-> StudentID char(6) primary key,
-> Name varchar(20),
-> gpa int
-> );
d) Write an SQL command to select all students with gpa greater than 2.7 (1.5mark)
Ans: SELECT* FROM student_info WHERE gpa>2.7;
e) Write an SQL command to select names of all the students (1mark)
Ans: SELECT* FROM student_info;
f) Write an SQL command to add a fifth record to the table with ID ST002, Name John,
gpa 3.0 (1.5mark)
Ans: insert into student_info(StudentID,Name,gpa) values(ST002, 'John', 3.0);
g) Write an SQL command to change the gpa of Suzy from 3.2 to 3.4 (1mark)
Ans: UPDATE student_info set gpa=3.4 WHERE gpa=3.2;

SECTION C: WEB DESIGN (15marks)

1. A website is different from a web application. Explain 4 marks


Answer:
- A website is a group of globally accessible, interlinked web pages, which have a single
domain name. Example Blog While A web application is a software or program which is
accessible using any web browser eg Facebook.
- Websites are static While web Application are dynamic
2. The figure below depicts the MVC architecture for web applications. Study each unit
carefully and answer the questions that follow

P a g e 8 | 10
i. State two formats used in transmitting HTTP Request/ HTTP Response between client
(Browser) and Server 2marks
Answer :
- Two formats
o XML
o JSON
ii. Using this architecture, explain in your own words all the activities that take place from
when a user submits his username and Password on a Facebook login form, to when he
receives his home page. 6 marks
Answer:

- The user submits his username and password from the browser
- Through the network, the information reaches the web server
- The web server processes the form data and removes harmful codes if present
- The server makes a query to the database for all users whose username and password
corresponds to what was submitted by the client (authentification).
- The DBMS runs the query and if there is a match (any user) then the DBMS provides the
response to the Web server.
- The server fills the home page with the information of the user and sends to the browser.
- The browser displays the response (home page) to the user in human readable format.

iii. State one example of DBMS mostly used for web applications 1mark
Answer:
- Example of DBMS:
o MySQL
iv. Explain two security measures offered by the browser to clients 2marks
Answer:
- It verifies SSL/TLS certificates and notify the user whether a site is secured or not
- It enables private browsing: which hides your browsing history from other users
- It combats against cyber criminals
P a g e 9 | 10
SECTION D: NETWORKING. (15marks)
You have been provided with 2 computers and one computer that will act as the central computer to
network and ensure that they should communication and share resources from a central computer
WORK REQUIRED
1. What is a network (1 marks)
2. What is a computer network (2 marks)
3. What is the most appropriate OS you think can be installed in both computers and the central
computer so as to ensure that proper file sharing and resource access should be ensured
(3marks)
4. List all the various networking tools you will need in course of this activity to ensure that
these two computers communicate with the central machine (3 marks)
5. Which other name can be given to the central machine (2marks)
6. Which other name can be given to the two computers connected to the central machine
(1mrks)
7. Which stand will you use to prepare your cables and why? (1marks)
8. LIST all the necessary configurations you think should be put in place and the various ping
commands to ensure that the computers are on a network and can communicate and share
resources (3 marks)

P a g e 10 | 10

You might also like