Homeworks
Introduction to Computer Programming w/C - I

Home
Lecture Notes
Textbook
Homeworks
Labs
Exams
Grades
 

Homework

Problem 1:  Input 3 test scores T1, T2, and T3 for a student. The final grade is found by

0.30 *T1 + 0.30 * T2 + 0.40 * T3.
The program should output ‘pass’ if final grade is greater than or equal to 70; ‘fail’ if final grade is less than 50 and ‘probation’ otherwise.

Problem 2: Calculate the volume of a sphere using the formula: (Use 3.1416 for Π, read r from user)

          4
V = --- Π r3
        3
Problem 3: Read in two integer numbers and store them in Num1 and Num2. Write a program to interchange the values contained in the memory locations Num1 and Num2, and print out the results.
Input: 3  5
Output:
Num1 is 3 N
Num2 is 5
Interchange is OK!
Num1 is 5 and Num2 is 3.
 

Homework

Problem 1: Assuming that M and N are integer variables with the values -5 and 8, respectively, and that X, Y, and Z are real variables with values -3.56, 0, and 44.7, respectively. Find the values of te following logical   expressions:

M < N
2* abs(M) < 8
X*X < sqrt(Z)
trunc(Z) == (6*N-3)
(X <= Y) && (Y <= Z)
! (X < Y)
! ((M <= N) && (X+Z > Y))
! ((M <= n) || !(X+Z > Y))
Problem 2: Assuming that A, B, and C are logical variables, use truth tables to display the values of the following logical expressions for all possible values of A, B, and C:
A || !B
! (A && B)
!A || !B
A && true || (1+2 == 4)
A && (B || C)
(A && B) || (A && C)
 

Last updated: July 28, 2001 16:08:56 +0300