How to find range of data types in C programming?

In C programming data types play a major role, so is their size and range. The sizeof() operator gives you bytes required to store value of some type in memory. However, in programming you must be aware of range of a type to avoid overflow and underflow errors.

The size of a data type is compiler dependent and so is its range. So, you must not hardcode size and range values in your program.

There are two ways to find minimum and maximum range of a type. You can use any of the approach to get range of a type.

Read more

C program to convert days to years weeks and days

Write a C program to input number of days from user and convert it to years, weeks and days. How to convert days to years, weeks in C programming. Logic to convert days to years, weeks and days in C program.

Example
Input

Enter days: 373

Output

373 days = 1 year/s, 1 week/s and 1 day/s

Read more

C program to convert temperature from degree fahrenheit to celsius

Write a C program to input temperature in degree Fahrenheit and convert it to degree Centigrade. How to convert temperature from Fahrenheit to Celsius in C programming. C program for temperature conversion. Logic to convert temperature from Fahrenheit to Celsius in C program.

Example
Input

Temperature in fahrenheit = 205

Output

Temperature in celsius = 96.11 C

Read more

C program to calculate Compound Interest

Write a C program to input principle (amount), time and rate (P, T, R) and find Compound Interest. How to calculate compound interest in C programming. Logic to calculate compound interest in C program.

Example
Input

Enter principle (amount): 1200
Enter time: 2
Enter rate: 5.4

Output

Compound Interest = 1333.099243

Read more

C program to calculate Simple Interest

Write a C program to input principle, time and rate (P, T, R) from user and find Simple Interest. How to calculate simple interest in C programming. Logic to find simple interest in C program.

Example
Input

Enter principle: 1200
Enter time: 2
Enter rate: 5.4

Output

Simple Interest = 129.600006

Read more

C program to calculate total average and percentage of five subjects

Write a C program to input marks of five subjects of a student and calculate total, average and percentage of all subjects. How to calculate total, average and percentage in C programming. Logic to find total, average and percentage in C program.

Example
Input

Enter marks of five subjects: 95 76 85 90 89

Output

Total = 435
Average = 87
Percentage = 87.00

Read more

C program to find square root of a number

Write a C program to input a number and find square root of the given number. How to find square root of a number in C programming using inbuilt sqrt() function. How to use predefined sqrt() function to find square root in C program.

Example
Input

Enter any number: 9

Output

Square root of 9 = 3

Read more

C program to find area of an equilateral triangle

Write a C program to input side of an equilateral triangle from user and find area of the given triangle. How to find area of an equilateral triangle in C programming. C program to calculate area of an equilateral triangle if its side is given.

Example

Input

Enter side of the equilateral triangle: 10

Output

Area of equilateral triangle = 43.3 sq. units

Read more