C program to find all roots of a quadratic equation using switch case
ExampleInput Input a: 4 Input b: -2 Input c: -10 Output Root1: 1.85 Root2: -1.35
Learn to Code and Code to Learn
Your Journey to Code Mastery
ExampleInput Input a: 4 Input b: -2 Input c: -10 Output Root1: 1.85 Root2: -1.35
ExampleInput Input number: 23 Output 23 is positive
ExampleInput Input number: 12 Output Even number
ExampleInput Input first number: 12 Input second number: 40 Output Maximum: 40
ExampleInput Input alphabet: c Output ‘c’ is consonant Another approach:
ExampleInput Input month number: 3 Output Total number of days = 31 Logic to print number of days in month using switch…case Total days in a month is given by below table. Month Total days January, March, May, July, August, October, December 31 days February 28/29 days April, June, September, November 30 days Step by step…
Read More “C program to print number of days in a month using switch case” »
ExampleInput Input week number(1-7): 2 Output Tuesday Logic to print day of week name using switch…case Step by step descriptive logic to print day name of week. Input day number from user. Store it in some variable say week. Switch the value of week i.e. use switch(week) and match with cases. There can be 7 possible values(choices) of week i.e. 1 to 7. Therefore…
Read More “C program to print day of week name using switch case” »
Write a C program to input electricity unit charge and calculate the total electricity bill according to the given condition:For first 50 units Rs. 0.50/unitFor next 100 units Rs. 0.75/unitFor next 100 units Rs. 1.20/unitFor unit above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the bill. Logic to calculate net electricity bill…
Write a C program to input basic salary of an employee and calculate gross salary according to given conditions.Basic Salary <= 10000 : HRA = 20%, DA = 80%Basic Salary is between 10001 to 20000 : HRA = 25%, DA = 90%Basic Salary >= 20001 : HRA = 30%, DA = 95% ExampleInput Input basic…
Read More “C program to enter basic salary and calculate gross salary of an employee” »
Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer, calculate percentage and grade according to given conditions:If percentage >= 90% : Grade AIf percentage >= 80% : Grade BIf percentage >= 70% : Grade CIf percentage >= 60% : Grade DIf percentage >= 40% : Grade EIf percentage…
Read More “C program to enter student marks and find percentage and grade” »