You are on page 1of 4

COLLEGE OF COMPUTER AND INFORMATION AND COMMUNICATIONS TECHNOLOGY

Information Technology Department


TechM 216
FUNDAMENTALS IN COMPUTER PROGRAMMING
Midterm Examination 1st Semester A.Y. 2021 -2022

Student Name: Edy Halen Tautho ID #:1204420 Section:BSTechM2-A

Part 1: Identification

Instruction: Identify the terms based on their definition.

1. An assignment operation assigns the value of the right-hand operand to the storage location
named by the left-hand operand. Assignment Operators
2. Used to perform arithmetic operations includes operators like Addition, Subtraction,
Multiplication, Division and Modulus. Arithmetic Operators
3. Used to evaluate two or more conditions. Logical Operators
4. Checks the relationship between two operands. If the relation is true, it returns 1; if the relation
is false, it returns value 0. Relational Operators
5. Used in C programming to perform bit-level operations. Bitwise Operator
6. Allows you to control if a program enters a section of code or not based on whether a given
condition is true or false. If statement
7. Used to perform the operations based on some specific condition. The operations specified in if
block is executed if and only if the given condition is true. If-else statement
8. The conditional expressions are evaluated from the top downward. As soon as a true condition
is found, the statement associated with it is executed, and the rest of the ladder is bypassed.
If-else-if Ladder
9. An if statement that is the target of another if statement. Nested if
10. Used to evaluate a condition that's applied to one or two Boolean expressions. The result of the
evaluation is either true or false. Conditional Operators
11. Allows a variable to be tested for equality against a list of values. Switch statement
12. A repetition control structure which allows us to write a loop that is executed a specific number
of times. For loop
13. Allows to repeatedly run the same block of code until a condition is met. "While" Loop
14. Used to repeat a section of code an unknown number of times until a specific condition is met.
Do while loop
15. The feature in C that allows the looping of statements inside another loop. Nesting of loops
16. Used to bring the program control out of the loop. Break Statement
17. Used to bring the program control to the beginning of the loop. Continue Statement
18. Calls all functions registered with at exit and terminates the program. File buffers are flushed,
streams are closed, and temporary files are deleted. Exit Program
19. Used to increase the value of the variable by one and decrement operators are used to decrease
the value of the variable by one. Increment operators
20. Used when two operators of same precedence appear in an expression. Operators Associativity

Prepared by: Lester D. Mabras


Part 2: Debugging (5 Points Each)

Instruction: Identify the error on each program below.

1 Arithmetic Operator
#include <stdio.h>
int main()
{
int a = 9,b = 4, c;
c = a+b;
printf("a+b = %d \n",c);
c = a-b;
printf("a-b = %d \n",c);
c = a*b;
printf("a*b = %d \n",c);
c = a/b;
printf("a/b = %d \n",c);
c = a%b;
printf("Remainder when a divided by b = %d \n",c);

return 0;
}

2 Assignment Operator
#include <stdio.h>
int main()

{
int a = 10, b = 100;
float c = 10.5, d = 100.5;
printf("+=a = %d \n", +a);
printf("-=b = %d \n", -b);
printf("++c = %f \n", ++c);
printf("--d = %f \n", --d);
return 0;
}

3 Bitwise Operator
XOR #include <stdio.h>
int main()
{
int a = 20;
int b = 21;
int c = 0;

c = a & b;
printf("AND - Value of c is %d\n", c );
c = a | b;
printf("OR - Value of c is %d\n", c );
c = a ^ b;
printf("Exclusive OR - Value of c is %d\n", c );
return 0;
}

Prepared by: Lester D. Mabras


4 if-else Ladder
#include<stdio.h>

int main()
{
int a,b,c;
printf("Enter three numbers: \n");
scanf("%d%d%d", &a, &b, &c);
if(a>b &+ a>c)
{
printf("Largest = %d", a);
}
else if(b>a &+ b>c)
{
printf("Largest = %d", b);
}
else
{
printf("Largest = %d", c);
}
return 0;
}

5 do-while Loop
#include <stdio.h>
int main() {
double number, sum = 0;

do {
printf("Enter a number: ");
scanf("%lf", &number);
sum += number;
}
while(number != 0.0);

printf("Sum = %.2lf",sum);

return 0;
}

Prepared by: Lester D. Mabras


Part 3: Application (20 Points Each)

Instruction: Program/Code the programs required below. Use the correct syntax of each program.
Students must be able to RUN the program to get the full 20points. IF not, Students will get half of the
points if the syntax are correct. Students that couldn’t run and use the correct syntax will not get any
points.

1. Conditional Operator

#include <stdio.h>
int main()
{
int age;
printf("To use this facility, you must be of legal age.\n ");
printf("input your age:");
scanf("%d", &age);
(age>=18)? (printf("\nYou met the minimum requirement to enter this facility")) :
(printf("\nYou didnt meet the minimum requirement to use this facility"));
return 0;
}

2. Nested Loops

#include <stdio.h>
int main() {
int i = 0;

while (i <= 20) {


printf("%d ", i);
++i;
}

return 0;
}

Prepared by: Lester D. Mabras

You might also like