Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Sunidhi Bansal
Page 9 of 81
C program to Calculate Body Mass Index (BMI)
Body Mass Index (BMI) is a health metric used to assess whether a person has a healthy body weight relative to their height. In C programming, we can calculate BMI using a simple formula. Syntax BMI = weight / (height * height) Where weight is in kilograms and height is in meters. Example: BMI Calculator This example demonstrates how to calculate BMI using a function − #include // Function to calculate BMI float calculateBMI(float weight, float height) { return weight / (height * height); } ...
Read MoreProgram to convert given number of days in terms of Years, Weeks and Days in C
You are given a number of days, and the task is to convert the given number of days in terms of years, weeks and days. Let us assume the number of days in a year = 365 (non-leap year). Syntax years = total_days / 365 weeks = (total_days % 365) / 7 days = (total_days % 365) % 7 Formula Explanation Number of years = (number of days) / 365 − The quotient obtained by dividing the given number of days with 365 Number of weeks = (number of days % 365) ...
Read MoreC Program for Armstrong Numbers
An Armstrong number (also known as narcissistic number) is a number that is equal to the sum of its own digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1³ + 5³ + 3³ = 1 + 125 + 27 = 153. Syntax int armstrong(int number); Formula For an n-digit number with digits d₁, d₂, ..., dₙ − Armstrong Number = d₁ⁿ + d₂ⁿ + ... + dₙⁿ Example: 153 (3-digit number) 1³ + 5³ + ...
Read MoreC Program for Area And Perimeter Of Rectangle
Given a length and breadth of a rectangle we have to find its area and perimeter. Rectangle is a 2-D figure containing four sides and four angles of 90 degrees each. All the sides of rectangle are not equal − only the opposite sides of a rectangle are equal. The diagonals in a rectangle also are of the same length. Syntax Area = Length × Breadth Perimeter = 2 × (Length + Breadth) Algorithm Length Breadth ...
Read MoreC Program for n-th odd number
Given a number N, we have to find the N-th odd number. Odd numbers are the numbers which are not completely divisible by 2 and their remainder is not zero, like 1, 3, 5, 7, 9, etc. If we closely observe the sequence of odd numbers, we can represent them mathematically as − 1st odd number: (2*1)-1 = 1 2nd odd number: (2*2)-1 = 3 3rd odd number: (2*3)-1 = 5 4th odd number: (2*4)-1 = 7 ... Nth odd number: (2*N)-1 So, to solve the problem we can simply multiply the number ...
Read MoreC Program for n-th even number
Given a number N we have to find the N-th even number. Even numbers are the numbers which are completely divided by 2 and their remainder is zero. Like 2, 4, 6, 8, 10, and so on. If we closely observe the list of even numbers we can also represent them as − 2*1=2, 2*2=4, 2*3=6, 2*4=8, ….2*N. So, to solve the problem we can simply multiply the number N with 2, so the result will be the number which is divisible by 2, i.e. the even number. Syntax nth_even_number = n * ...
Read MoreProgram to Convert Radian to Degree in C
Converting radians to degrees is a common mathematical operation in C programming. A radian is the standard unit for measuring angles in mathematics, while degrees are commonly used in everyday applications. The complete angle of a circle is 360 degrees or 2π radians. Syntax degree = radian × (180 / π) Where π (pi) ≈ 3.14159 or can be approximated as 22/7. Conversion Formula The mathematical relationship between radians and degrees is − degree = radian × (180/π) where, π = 3.14159 For example, if radian = 9.0, then ...
Read MoreProgram for Identity Matrix in C
Given a square matrix M[r][c] where 'r' is some number of rows and 'c' are columns such that r = c, we have to check that 'M' is identity matrix or not. Identity Matrix Identity matrix is also known as Unit matrix of size nxn square matrix where diagonal elements will only have integer value one and non diagonal elements will only have integer value as 0. Like in the given Example below − I₁ = [1] I₂ = ...
Read MoreProgram to Convert Centimeter to Feet and Inches in C
Given with the length in centimeters as an input, the task is to convert the given length into feet and inches using C programming. We can use length conversion formulas for this − 1 feet = 30.48 cm 1 inch = 2.54 cm Syntax double inches = centimeters * 0.3937; double feet = centimeters * 0.0328; Algorithm Start Step 1 → Declare function to perform conversion double convert(int centimeter) set double inch = 0.3937 * centimeter ...
Read MoreProgram to Calculate the Perimeter of a Decagon in C program
A decagon is a polygon with 10 sides and 10 vertices. In a regular decagon, all sides are equal in length and each internal angle measures 144 degrees. The perimeter of any polygon is the sum of all its side lengths. V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 ...
Read More