Expressions and Conditional Statements (Discount) ID-3454

Discount for Railway Employees (Id-3454)
The following is a hypothetical condition. There are different cadre of employees in railways department. There are four cadres of employees ‘A’, ‘B’, ‘C’ and ‘D’. Each cadre has different rate of discount as follows:

‘A’ – 10%

‘B’ - 8%

‘C’ – 6%

‘D’ – 5%

Given the cadre of employee, develop an algorithm and write the ‘C’ program to print the rate of discount for the employee. The input shall be given in upper or lower case letter. Print ‘Invalid input’ if the input is any other character

Input Format

First line contains the cadre of employee, this input shall be given in upper or lower case

Output Format
Print the discount percentage for the employee. Print ‘%’ symbol at the end of the output
sol:- 
C-CODE: 
#include<stdio.h>
int main()
{
    char x;
    scanf("%c",&x);
    if(x=='A'||x=='a'){
        printf("10%%");}
    else if(x=='B'||x=='b'){
    printf("8%%");}
    else if(x=='C'||x=='c'){
    printf("6%%");}
    else if(x=='D'||x=='d'){
    printf("5%%");}
    else{
        printf("Invalid input");}
}

Post a Comment

0 Comments