1. | Write a C program to output the first n non-negative integers. Sample Output |
|||||||||||||||||||||||||
2. | Write a C program to input the mark of a student. The mark should lie in between 0 and 100 inclusively. Sample Output Enter the mark = 101 Enter the mark = 83 |
|||||||||||||||||||||||||
3. | Write a C program to sum up a sequence of integers. Sample Output Number 2 = 22 Number 3 = 8 Number 4 = 24 Sum = 69 |
|||||||||||||||||||||||||
4. | Write a C program to solve the quadratic equation:
Sample Output Solving quadratic equation: ax^2+bx+c=0 a = 0 a can't be equal to 0 a = 1 b = 2 c = 7 No real root Continue (yes=1/no=0)? 1 Solving quadratic equation: ax^2+bx+c=0 a = 1 b = -1 c = -2 There are two real roots. They are -1 and 2. Continue (yes=1/no=0)? 1 Solving quadratic equation: ax^2+bx+c=0 a = 1 b = -6 c = 9 There is an equal root. It is 3. Continue (yes=1/no=0)? 0 |
|||||||||||||||||||||||||
5. | Write a C program to input a sequence of positive numbers and then generate the corresponding statistics. The end of data is indicated
by the number 0. |
|||||||||||||||||||||||||
6. | In a certain country, the allowance given to taxpayers in the calculation of net chargeable income is shown in table 1. The tax to be paid is calculated by using table 2. (N.B. Net chargeable income = annual income - total allowance)
The tax paid should not be greater than 25% of the total annual income. Write a C program to generate the following sample output. (C program) Sample Output Name? Cheung Wai Yee Total annual income? -1000 Total annual income? 120000 Marital status (1=Single, 2=Married)? 3 Marital status (1=Single, 2=Married)? 1 Number of dependent parents? -2 Number of dependent parents? 0 Tax for Cheung_Wai_Yee is $21000 Any more (yes=1/no=0)? 1 Name? So Siu Ming Total annual income? 10000000 Marital status (1=Single, 2=Married)? 2 Number of children? 5 Number of dependent parents? 4 Tax for So_Siu_Ming is $2500000 Any more (yes=1/no=0)? 1 Name? Wong Ching Man Total annual income? 110000 Marital status (1=Single, 2=Married)? 2 Number of children? 1 Number of dependent parents? 1 Tax for Wong_Ching_Man is $3000 Any more (yes=1/no=0)? 1 Name? Lo Yuen Kam Total annual income? 110000 Marital status (1=Single, 2=Married)? 2 Number of children? 0 Number of dependent parents? 0 Tax for Lo_Yuen_Kam is $9000 Any more (yes=1/no=0)? 0 |
|||||||||||||||||||||||||