Anda di halaman 1dari 10

SCHOOL: UCT-HIT

COURSE: COMPUTER PROGRAMMING FOR ENGINEERS


TERM: FIRST SEMESTER EXAM
INSTRUCTOR: Engineer LUCIEN WENGIE YEMAH
DURATION:
Instruction: ANSWER ALL QUESTIONS

SECTION A
MCQS
This section deals with mcqs from tools like codeblocks, Matlab, wampserver, etc
1. Which of the following operator takes only integer operands?

A. +

B. *

C. /

D. %

E. None of these
2. In C programming language, which of the following type of operators have the highest
precedence

A. Relational operators

B. Equality operators

C. Logical operators

D. Arithmetic operators
3. What will be the output of the following program?
void main()
{
int a, b, c, d;
a = 3;
b = 5;

1
c = a, b;
d = (a, b);
printf("c=%d d=%d", c, d);
}

A. c=3 d=3

B. c=3 d=5

C. c=5 d=3

D. c=5 d=5

4. C programs are converted into machine language with the help of

A. An Editor

B. A compiler

C. An operating system

D. None of these.
5. A C variable cannot start with

A. A number

B. A special symbol other than underscore

C. Both of the above

D. An alphabet
6. What will be printed after execution of the following program code?
main()
{
printf("\\nab");
printf("\\bsi");
printf("\\rha");
}

A. absiha
2
B. asiha

C. haasi

D. hai

E. None of these

7. Which is the only function all C programs must contain?

A. start()

B. system()

C. main()

D. printf()

E. getch()
8. What will be the output of the given program?
#include<stdio.h>
void main()
{
int i=10;
printf("i=%d", i);
{
int i=20;
printf("i=%d", i);
i++;
printf("i=%d", i);
}
printf("i=%d", i);
}

A. 10 10 11 11

B. 10 20 21 21

3
C. 10 20 21 10

D. 10 20 21 20

9. What is the output of given program if user enter value 99?


#include<stdio.h>
void main()

{
int i;
printf("Enter a number:");
scanf("%d", &i); // 99 is given as input.
if(i%5 == 0){
printf("nNumber entered is divisible by 5");
}
}

A. Enter a number:99

B. Enter a number:99 Number is divisible by 5

C. complier error

D. Run time error


10. What is right way to Initialize array?

A. int num[6] = { 2, 4, 12, 5, 45, 5 };

B. int n{} = { 2, 4, 12, 5, 45, 5 };

C. int n{6} = { 2, 4, 12 };

D. int n(6) = { 2, 4, 12, 5, 45, 5 };


11. What will be the output of the program ?
#include
int main()
4
{
int arr[1] = {10};
printf("%d", 0[arr]);
return 0;
}

A. 1

B. 0

C. 10

D. 6

E. None of these
12. Which of the following statements are correct about an array?
1. The array int num[26]; can store 26 elements.
2. The expression num[1] designates the very first element in the array.
3. It is necessary to initialize the array at the time of declaration.
4. The declaration num[SIZE] is allowed if SIZE is a macro.

A. 1

B. 1, 4

C. 2, 3

D. 2, 4

E. None of these
13. What is function?

A. Function is a block of statements that perform some specific task.

B. Function is the fundamental modular unit. A function is usually designed to perform a


specific task.

C. Function is a block of code that performs a specific task. It has a name and it is reusable.

D. All of the above


14. The default parameter passing mechanism is

A. call by value

5
B. call by reference

C. call by value result

D. None of these.
15. Which of the following is a complete function?

A. int funct();

B. int funct(int x) { return x=x+1; }

C. void funct(int) { printf(Hello"); }

D. void funct(x) { printf(Hello"); }

E. None of these
16. What is the full form of SQL?

A. Structured Query Language

B. Structured Query List

C. Simple Query Language

D. None of these
17. In SQL, which command(s) is(are) used to change a table's storage characteristics?

A. ALTER TABLE

B. MODIFY TABLE

C. CHANGE TABLE

D. All of the above


18. A command that lets you change one or more fields in a record is

A. Insert

B. Modify

C. Look-up

D. All of the above


19. Which of the SQL statements is correct?

6
A. SELECT Username AND Password FROM Users

B. SELECT Username, Password FROM Users

C. SELECT Username, Password WHERE Username = 'user1'

D. None of these
20. The FROM SQL clause is used to...

A. specify what table we are selecting or deleting data FROM

B. specify range for search condition

C. specify search condition

D. None of these
21. Which of the following SQL commands is used to retrieve data?

A. DELETE

B. INSERT

C. SELECT

D. JOIN
22. Which SQL statement is used to update data in a database?

A. SAVE

B. UPDATE

C. SAVE AS

D. MODIFY
23. What does Matlab stand for?
a) Math Laboratory
b) Matrix Laboratory
c) Mathworks
d) Nothing
e) none of the above

24. What symbol precedes all comments in Matlab?


a)
b) %
7
c) //
d) none of the above

25. Which of the following is not a pre-defined variable in Matlab.


a) pi
b) inf
c) i
d) gravity
e) j

26. This Matlab command clears all data and variables stored in memory:
a) clc
b) clear
c) delete
d) deallocate
e) none of the above
27. To print a newline in a fprintf statement, you must use the following escape character:
a) \t
b) \nl
c) \nxt
d) \n
e) none of the above
28. In Matlab, this keyword immediately moves to the next iteration of the loop:
a) update
b) goto
c) continue
d) break
e) none of the above

29. Which of these is the way to access the first element in a vector named v (assuming there is
atleast one element in the vector)?
a) v(0)
b) v(1)
c) v
d) v(: , 0)
e) none of the above

30. Which of the following is used to see if two elements are equal in MATLAB?
a) !=
b) ==
c) isequal
d) =
e) none of the above

8
SECTION B
PART 1: STRUCTURAL
1 Outline two (2) good programming practice that makes a code a code.
2 what does the statement #include <stdio.h> means?
3 list the three control structure used in C programming
4 how can functions be called in c programming?

5 The statement int array [4][3] is the definition of an array. Whats the meaning of [4][3]?
6 How many memory banks does the microcontroller PIC16F84A has as used in proteus and list
the function of each bank
8 list the most common registers that are found on bank 0 and list their function
9 To switch between segments of codes in Assembly language programming what is the
command used?
10 what is the command use to see the number of databases, to enter a particular database
(database name is user), to delete an entire database.
11 In batch programming, what command is used to print information on the screen?
12 In excel, 5 6 how will you add 5 to 6 automatically given that 5 is on E3 and 6
is on E4?

13 In MS Word, what is one of the ways of making your document authentic?


14 In Matlab, how can you prevent the display of an initialized variable?
15 what is the command use in plotting a graph of y against x on a grid?
16 how can you remove all information stored in memory?
17 In VHDL, the code is divided into two parts, list them.
18 List the function of each part
19 What is the full meaning of FPGA?
20 What is the tool used in synthesizing a VHDL code?
PART 2
Practical Application
In combinational logic, a HALF ADDER takes three inputs A and B, adds them to produce
two output sum S and carry C. The logic combinations of the sum and carry is as follows
Sum (S) = A XOR B

9
Carry (C) = A AND B.
Write a VHDL code for the above illustration.

10

Anda mungkin juga menyukai