Professional Documents
Culture Documents
ICS - 103 - Assignment1 - Answers
ICS - 103 - Assignment1 - Answers
Key
Answers
1
Prepared by: sabiha
1. Choose the correct answer for each question below:
1. When writing comments on multi lines, we use__________.
a) /* and */
b) //
c) <!
a) start()
b) system()
c) main()
13. Which of the following declarations could store the number 5.5?
a) char num;
b) intnum;
c) double num;
14. What value would be stored in an integer variable "i" as a result of the following
calculation:
int i, j;
j=3;
i = 4 + 2 * j / ( j - 1 );
a) 1
b) 7
c) 9
15. What is the value of the following arithmetic expression as evaluated by a C compiler?
(3 + 4)/( 7 - 6%4)
a) 1
b) 1.4
c) 7
25. Which of the following is a correct declaration for a variable which takes value of 15.5?
a) int m =15.5;
b) double m =15.5
c) Double m=15.5
a= 1;
b= 2;
c= 3;
a = a + 3;
b = b + 1;
c = a + b;
printf(“ a = %d, b=%d, c=%d” , a, b, c);
system("pause");
return 0;
}
6 5 9 . 4 6
4. What #include statement do you put at the top of a program that does uses printf or
scanf?
#include <stdio.h>
int N=10;
6. Evaluate 4+5*3
19
7. Evaluate 7*3+2
23
8. Evaluate 7*(3+2)
35
9. Evaluate the following expressions that use thearithmetic operators where i = 10, j = 2,
and k = 3.
Expression Result
i-j*k i-j*k
10-2*3
10-6
4
i-i/j i-i/j
10-10/2
10-5
5
i%k+j i%k+j
10 % 3 + 2
1+2
3
i%2*k i%2*k
10 % 2 * 3
0*3
0
i+j*k-i/j i+j*k-i/j
10 + 2 * 3 - 10 / 2
10+6- 10 / 2
10+6-5
16-5
11