[SOLVED] IT1010 - Tutorial 6  - Introduction to Programming 

30.00 $

Category:

Description

5/5 - (1 vote)

Question 1

 

Draw a flowchart to input an integer from the keyboard and display whether the number is positive, negative or zero. If the number is > 0 display “number is positive”. If number is zero display “ Number is zero”. Otherwise display “Number is negative”.

 

Convert the flowchart to a C program.

 

Question 2

 

Draw a flow chart to enter a number from the keyboard and print whether it is an even number or an odd number.

 

Convert the flowchart to a C program.

 

 

Question 3

 

A palindrome is a number or a text phrase that reads the same backward as forward. For example 12321, 45554. Write a C program that reads a five-digit integer and determines whether it is a palindrome or not.

 

Question 4

 

Write a C program to input the grade from the keyboard and print the respective messages.

 

Question 5

 

Re-write the answer for question 4 using switch statements.

 

 

Question 6

Convert the following switch statement to an equivalent if-else statement.

 

switch ( grade ) {

case ‘A’ : printf( “Excellent \n”);

break;

case ‘B’ : printf( “Good \n”); break;

case ‘c’ :

case ‘C’ : printf( “OK \n”); break;

default : printf( “Needs Improvement\n”);

}

 

Question 7

 

A company calculates the bonus given to their employees based on the employee category.  Write a C program to input the employee category and basic salary and calculate the bonus amount.

 

Employee category                 Bonus percentage

  • 5%
  • 10%
  • 15%

 

Bonus = Basic_Salary * Bonus_Rate