C program to calculate profit or loss
ExampleInput Input cost price: 1000 Input selling price: 1500 Output Profit: 500
Learn to Code and Code to Learn
Your Journey to Code Mastery
ExampleInput Input cost price: 1000 Input selling price: 1500 Output Profit: 500
ExampleInput Input a: 8 Input b: -4 Input c: -2 Output Root1: 0.80 Root2: -0.30 Quadratic equation Wikipedia states, in elementary algebra a quadratic equation is an equation in the form of Logic to find all roots of a quadratic equation Based on the above formula let us write step by step descriptive logic to…
Read More “C program to find all roots of a quadratic equation” »
ExampleInput Input first side: 30 Input second side: 30 Input third side: 30 Output Triangle is equilateral triangle Logic to check equilateral, scalene or isosceles triangle Step by step descriptive logic to classify triangle as equilateral, scalene or isosceles triangle. Input sides of a triangle from user. Store it in some variables say side1, side2 and side3. Check if(side1 ==…
Read More “C program to check whether triangle is equilateral, scalene or isosceles” »
ExampleInput Input first side: 7 Input second side: 10 Input third side: 5 Output Triangle is valid Property of triangle A triangle is valid if sum of its two sides is greater than the third side. Means if a, b, c are three sides of a triangle. Then the triangle is valid if all three conditions are…
Read More “C program to check whether triangle is valid or not if sides are given” »
ExampleInput Input first angle: 60 Input second angle: 30 Input third angle: 90 Output The triangle is valid Property of a triangle A triangle is said to be a valid triangle if and only if sum of its angles is 180 °. Logic to check triangle validity if angles are given Step by step descriptive logic…
Read More “C program to check whether triangle is valid or not if angles are given” »
ExampleInput Input amount: 575 Output Total number of notes: 500: 1 100: 0 50: 1 20: 1 10: 0 5: 1 2: 0 1: 0 Logic to count minimum number of denomination for given amount There any many optimal algorithms to solve the given problem. For this exercise to make things simple I have used…
Read More “C program to count total number of notes in given amount” »
ExampleInput Enter month number: 1 Output It contains 31 days. Logic to find number of days in a month Total days in a months 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 descriptive logic…
ExampleInput Input week number: 1 Output Monday Program to print day name of week using array constant
ExampleInput Input character: C Output ‘C’ is uppercase alphabet Program to check uppercase or lowercase characters using library functions
ExampleInput Input any character: 3 Output 3 is digit Program to check alphabet, digit or special character using ASCII value