Tag Archives: If else

C program to enter student marks and find percentage and grade

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 A
If percentage >= 80% : Grade B
If percentage >= 70% : Grade C
If percentage >= 60% : Grade D
If percentage >= 40% : Grade E
If percentage < 40% : Grade F

Example
Input

Input marks of five subjects: 95
95
97
98
90

Output

Percentage = 95.00 
Grade A

Continue reading C program to enter student marks and find percentage and grade

C program to calculate profit or loss

Write a C program to input cost price and selling price of a product and check profit or loss. Also calculate total profit or loss using if else. How to calculate profit or loss on any product using if else in C programming. Program to calculate profit and loss of any product in C.

Example
Input

Input cost price: 1000
Input selling price: 1500

Output

Profit: 500

Continue reading C program to calculate profit or loss

C program to check whether a number is divisible by 5 and 11 or not

Write a C program to check whether a number is divisible by 5 and 11 or not using if else. How to check divisibility of any number in C programming. C program to enter any number and check whether it is divisible by 5 and 11 or not. Logic to check divisibility of a number in C program.

Example
Input

Input number: 55

Output

Number is divisible by 5 and 11

Continue reading C program to check whether a number is divisible by 5 and 11 or not

C program to check whether triangle is equilateral, scalene or isosceles

Write a C program to input sides of a triangle and check whether a triangle is equilateral, scalene or isosceles triangle using if else. How to check whether a triangle is equilateral, scalene or isosceles triangle in C programming. Logic to classify triangles as equilateral, scalene or isosceles triangle if sides are given in C program.

Example
Input

Input first side: 30
Input second side: 30
Input third side: 30

Output

Triangle is equilateral triangle

Continue reading C program to check whether triangle is equilateral, scalene or isosceles

C program to check whether triangle is valid or not if sides are given

Write a C program to input side of a triangle and check whether triangle is valid or not using if else. How to check whether a triangle can be formed or not if sides of triangle is given using if else in C programming. Logic to check triangle validity if sides are given in C program.

Example
Input

Input first side: 7
Input second side: 10
Input third side: 5

Output

Triangle is valid

Continue reading C program to check whether triangle is valid or not if sides are given

C program to check whether triangle is valid or not if angles are given

Write a C program to check whether a triangle is valid or not if angles are given using if else. How to check whether a triangle can be formed or not, if its angles are given using if else in C programming. Logic to check triangle validity if angles are given in C program.

Example
Input

Input first angle: 60
Input second angle: 30
Input third angle: 90

Output

The triangle is valid

Continue reading C program to check whether triangle is valid or not if angles are given

C program to check whether a character is alphabet, digit or special character

Write a C program to input a character from user and check whether given character is alphabet, digit or special character using if else. How to check if a character is alphabet, digits or any other special character using if else in C programming. Logic to check alphabet, digit or special character in C programming.

Example
Input

Input any character: 3

Output

3 is digit

Continue reading C program to check whether a character is alphabet, digit or special character