Posts

C program Simple Interest and Compound Interest

This is a C programming code which calculates banking interest on principle amount for N years using Simple interest formula and Compound Interest formula. The input values for principle amount and number of years is read from user. Simple interest - formula I - Interest Amount P - Principle Amount to be deposited N - Number of years the principle amount to be deposited R - Rate of interest per year in percentage Simple interest - example calculation Assume that, we are going to deposit 5000$ in bank at rate of interest 8% for 5 years, calculate simple interest for the principle amount after 5 years P=5000; R =8; N=5; I =? I = 5000 x 5 x 8/100 I = 25000 x 0.08 I = 2000$ after 5 years , we will get additionally 2000$ as interest along with principle amount (10000$)

Number System Binary to Octal Conversion

Image
It is a C program which executes number system conversion from binary to octal numbers. Binary to Octal - algorithm set octal [] Read binary_bits form user reverse(binary_bits) while not EOF(binary_bits) read 3-bits from binary_bits convert 3-bits to decimal append decimal to octal end print reverse(octal) Binary to Octal conversion example The given binary number is 01101010010 and converts it into octal number binary = 01101010010, octal = ?, split binary 3 bits group from right to left direction and carried out binary to decimal conversion on each 3 bits group binary = 01 | 101 | 010 | 010 octal = 1 5 2 2 if

Convert Octal to Binary

Image
The C program carry out number system conversion from a octal value (base-8) to binary numbers (base-2) is called octal to binary conversion. A octal number is represented by binary 3 bits. Octal number system The octal number system has the following unique digits. {0, 1, 2, 3, 4, 5, 6, 7} As the octal number system has the 8 unique digits, it is called base 8 or radix 8 number system. Each octal digit can be represented by binary 3 bits. Binary number system The Binary number system has the following unique digits. {0, 1} As the binary number system has the 2 unique digits, it is called base 2 or radix 2 number system. The computer can only understand this number system and is operated by this binary number system, therefore it accepts data,instruction and everything in binary numbers format. Octal to Binary conversion example

Binary to Hexadecimal Conversion

Image
The number system conversion C program which converts binary number to a hexadecimal number, is called binary to hexadecimal conversion. alternatively, it is said be a conversion from base-2 to base-16 number system or radix-2 to radix-16 number system conversion. Binary to Hexadecimal - algorithm set hexa =[] Read binary_bits form user reverse(binary_bits) while not EOF(binary_bits) read 4-bits from binary_bits convert 4-bits to decimal append decimal to hexa end print reverse(hexa) Binary to Hexadecimal conversion example The given binary number is 11101101010110 and converts it into hexadecimal number binary = 11 1011 0101 0110, hexadecimal = ?, 1. split binary numbers into 4

Hexadecimal to Binary Conversion

Image
The number system conversion from hexadecimal number to binary number is explained by algorithm steps and it is tested by C programming implementation. Hexadecimal number system The hexadecimal number system has the following unique digits. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f} As the hexadecimal number system has the 16 unique digits, it is called base 16 or radix 16 number system. Each hexadecimal digit can be represented by binary 4 bits, therefore the hexadecimal numbers helps remember long binary sequence. Binary number system The Binary number system has the following unique digits. {0, 1} As the binary number system has the 2 unique digits, it is called base 2 or radix 2 number system. The computer can only understand or is operated by binary number system, therefore it accepts data,instruction and everything in binary numbers format.

C programming Minimum and Maximum of Numbers

It has two C programming code to find minimum value and maximum value of numbers, they are Minimum of Numbers - The input of the program is N numbers and the output is minimum of given inputs Maximum of Numbers - The input of the program is N numbers and the output is maximum of given inputs Minimum of array of numbers - Algorithm set min=INT_MAX Read N integers For i=1 : N IF integers[i] < min then min =integers[i] End IF End For print min Maximum of array of numbers - Algorithm set max=0 Read N integers For i=1 : N IF integers[i] > max then max =integers[i] End IF End For print max Minimum of Numbers - C programming code The C program reads N integers from user while the program is

C program Sum and Average of N numbers

It has two C program to do sum and average of N numbers. Sum of N numbers - N integers are given to it as input and return sum of input integers as result Average of N numbers - N integers are given to it as input and return average of inputs integers as result Sum of N numbers - algorithm The input N integers read from user add the N integers store result into a variable sum. and then prints sum value after end of loop. set sum=0 Read N integers For i=1 to N sum = sum + integers[i] End For print sum Average of N numbers - algorithm The input N integers read from user add the N integers store result into a variable sum. after end of loop, divide sum value by N and store results into a variable average, then prints average value . set su