C program to print natural numbers in reverse from n to 1
Example Input Input N: 10 Output Natural numbers from 10-1 in reverse: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 Program to print natural number in reverse in given range
Learn to Code and Code to Learn
Your Journey to Code Mastery
Example Input Input N: 10 Output Natural numbers from 10-1 in reverse: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 Program to print natural number in reverse in given range
Example Input Input upper limit to print natural numbers: 10 Output Natural numbers from 1 to 10: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
ExampleInput 5.2 – 3 Output 2.2 Logic to create calculator using switch…case Step by step descriptive logic to create menu driven calculator that performs all basic arithmetic operations. Input two numbers and a character from user in the given format. Store them in some variable say num1, op and num2. Switch the value of op i.e. switch(op). There are four possible values of op i.e. ‘+’, ‘-‘, ‘*’ and ‘/’. For case…
Read More “C program to create calculator using switch case and functions” »
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” »