Thứ Hai, 30 tháng 11, 2015

Session 16.

16.1 Functions


16.2 Use of parameters in functions


16.3 Write a C program that accepts a number and square the number with the help of a function.


Bài 1: Write a C program to find the area and perimeter of a circle.


Bài 2: Write a C program to calculate the factorial of an integer.





Thứ Hai, 16 tháng 11, 2015

Session 10

10.1 Using the ‘for’ Loop

10.2 Using the ‘while’ Loop

10.3 Using do-while Loop


10.4 Using the break statement

10.5 Using the continue statement

Part II – For the next 30 Minutes:
1. Find the factorial of a number.


1. Declare a variable which has the age of the person. Print the user’s name as many times as his age.


2.Write a program to generate the following pattern:11 21 2 31 2 3 41 2 3 4 51 2 3 4 5 61 2 3 4 5 6 71 2 3 4 5 6 7 81 2 3 4 5 6 7 8 9


3.Write a program to print a multiplication table for a given number.



Thứ Sáu, 13 tháng 11, 2015

Session8 + Try it yourself

Part I.

1. Calcullating the commission

2. The 'if...else' statement.

3. The 'if...else...if' statement.

4. The 'Nested if' statement.

5.Using the 'switch' statement.

Part II

1. A student appears for a test in 3 subjects. Each test is out of 100 marks. The percentage of each student has to be calculated and depending on the percentage calculated, grades are given as under:
Percentage Grade
>=90          E +
80 - < 90    E
70 - < 80    A +
60 - < 70    A
50 - < 60    B +
< 50           FAIL
To do this :a. Accept the marks of 3 subjects and store in 3 different variables say M1, M2 and M3.b. Calculate the percentage (per = (M1 + M2 + M3) / 3 )c. Check the grade depending on the percentage calculated.d. Display the grade.

Part III.

Bài 1: Declare two variables x and y. Assign values to these variables. Number x should be printed only if it is less than 2000 or greater than 3000, and number y should be printed only if it is between 100 and 500.

Bài 2: Write a program to show your computer’s capabilities. The user types in a letter of the
alphabet and your program should display the corresponding language or package
available. Some sample input and output is given below :
Input                         Output
A or a                           Ada
B or b                           Basic
C or c                           COBOL
D or d                          dBASE III
f or F                            Fortran
p or P                           Pascal
v or V                          Visual C++


Bài 3: Accept values in three variables and print the highest value.








Try it yourself session 7

1.Write a program that accepts two numbers a and b and checks whether or not a is divisible by b.


2.Write a program to accept 2 numbers and tell whether the product of the two numbers is equal to or greater than 1000.


3.Write a program to accept 2 numbers. Calculate the difference between the two values.
If the difference is equal to any of the values entered, then display the following message:
Difference is equal to value <number of value entered>
If the difference is not equal to any of the values entered, display the following message:
Difference is not equal to any of the values entered



4. Montek company gives allowances to its employees depending on their grade as follows:Grade AllowanceA 300B 250Others 100Calculate the salary at the end of the month. (Accept Salary and Grade from the user).


5. Write a program to evaluate the Grade of a student for the following constraints:
If marks > 75 – grade A
If 60 < marks < 75 – grade B
If 45 < marks<60 – grade C
If 35 < marks<45 - grade D
If marks < 35 – grade E


Thứ Tư, 11 tháng 11, 2015

session 5

1. Calculating Simple Interest



2. Using Arithemetic Operators



3. Using Comparison and Logical operators



4. Using Type-conversion



5. Precedence of operators



Try it yourself session 6

1.    A. Use the printf() statement and do the following:

a. Print out the value of the integer variable sum
b. Print out the text string “Welcome”, followed by a new line.
c. Print out the character variable letter.
d. Print out the float variable discount.
e. Print out the float variable dump using two decimal places.


        B. Use the scanf() statement and do the following:

a. To read a decimal value from the keyboard, into the integer variable sum
b. To read a float variable into the variable discount_rate


2. Write a program which prints the ASCII values of the characters ‘A’ and ‘b’.


4. Write a program which takes name, basic , daper ( ie, percentage of D.A), bonper (ie, percentage bonus) and loandet ( loan amount to be debited) for an employee. Calculate the salary using the following relation:

salary = basic + basic * daper /100 +bonper * basic/100 - loandet
Data is:
name           basic     daper      bonper       loandet
M A R K     2500      55            33.33          250.00
Calculate salary and then print the result under the following headings.
(Salary to be printed to the nearest dollar.)
Name                            Basic                        Salary


5. Write a program that asks for your first name and last name, and then prints the names in the format last name, first name.



Try it yourself session 4

1. Write a program to accept and add three numbers:

2. For the following values, write a program to evaluate the expression

z = a*b + (c/d) - e*f
a=10,  b=7, c = 15.75, d=4, e=2, f=5.6


3. write a program to evaluate the area and perimeter of the rectangle

4. Write a program to evaluate the volume of a cylinder.


5. Write a program to evaluate the net salary of an employee given the following constrains:


Thứ Bảy, 7 tháng 11, 2015

Session 1: Try it yourself

1.      Write a pseodo code and draw a flowchart to accept a value in degrees Celsius and to convert it into Fahrenheit.

Pseodo code:                            Flowchart:



Begin
   Input C
   F = 9*C/5 + 32
  Display 
End








2.      Write a pseodo code and flowchart to accept a student’s marks in physics, chemistry, and Biology. The total of these marks as well as the average should be displayed.

Pseodo code                                   Flowchart:

            
Begin
    Input Phy, Che, Bio
    Total = Phy + Che + Bio
    Average = Total / 3
    Display Total, Average
End


Session 3

Ví dụ 1:


Ví dụ 2: 


Bài 1: Write a C program that accepts a number and square the number: 


Try it yourself bài 1: Write a C program to find the area and perimeter of a circle.


Try it yourself bài 2: Write a C program that accepts the salary and age from user and display the same on the screen as output.