# Monthly Archives: August 2013

## An C program to Multiply two matrices (matrix)

Let’s identify variables needed for this program. In this program, we need to save matrices which consists Rows and Columns. To save this we need Two dimensional ARRAY. Multi dimensional Array is a nothing different than any Array but the only difference is that it has more than one deminsion to it e.g. square has… Read More »

## A C program to Add two matrices (matrix) or Subtract two matrices (matrix)

Let’s identify variables needed for this program. In this program, we need to save matrices which consists Rows and Columns. To save this we need Two dimensional ARRAY. Multi dimensional Array is a nothing different than any Array but the only difference is that it has more than one deminsion to it e.g. square has… Read More »

## C014 An interactive C program that will take as input a set of 20 integers and store them in an array and using a temporary array of equal length, reverse the order of the integers & display the values.

Let’s identify variables needed for this program. In this program, we need several variables to store and compare the values to find the largest and the smallest out of them. Its not recommended to take number of variables declared of the same data type with different names and remembering it. It becomes worst when the… Read More »

## C013 A C program that will take as input a set of integers and find and display the largest and the smallest values within the input data values

Let’s identify variables needed for this program. In this program, we need several variables to store and compare the values to find the largest and the smallest out of them. Its not recommended to take number of variables declared of the same data type with different names and remembering it. It becomes worst when the… Read More »

## C012 A C program that uses macros, MIN & MAX, to find and return, respectively the minimum & maximum of two values

Macro are the small code which is substituted wherever the macro is refered. macros can be used in two ways : First way as a replacement to the code which is long in length or repeated all the time.  e.g. #define CUBE(X) (X*X*X) Second way as a small function in which we can pass arguments… Read More »

## C011 A C program to write a function that calculates the compounded interest amount for a given initial amount, interest rate & no. of years. The interest is compounded annually. The return value will be the interest amount

First thing to know before writing this program is the Simple interest Formula. COMPOUND INTEREST = (P *(1+R) N) P = PRINCIPAL AMOUNT. N = NUMBER OF YEARS (TIME). R = RATE OF INTEREST. Here the problem is the rate of interest should be in the form of 0.10 instead of 10%. Now, find out the variables… Read More »

## C010 A C program to write a function invert(x, p, n) that returns x with the n bits that begin at position p inverted. You can assume that x, p & n are integer variables and that the function will return an integer

As an example, if x = 181 in decimal which is 10110101 in binary, and p = 4 and n = 2, then the function will return 10101101 or 173 in decimal. The underlined bits are the changed bits. Note that bit positions are counted from the right to the left and that the counts… Read More »

## C009 An interactive C program to find the roots of a Quadratic equation

First thing to know before writing this program is the Quadratic Equation Formula. Here the problem is the this whole Quadratic Equation can not be written on single line. Now, find out the variables needed for calculating Roots of Quadratic Equation. X1 = (-B-Square Root(b 2 – 4AC))/2A    AND   X2 = (-B+Square Root(b 2 – 4AC))/2A… Read More »

## C008 An interactive C program to check whether given two numbers are amicable numbers or not

Amicable numbers are two numbers so related that the sum of the proper divisors of the one is equal to the other, unity being considered as a proper divisor but not the number itself. Let’s identify variables needed for this program. First two variables will be the one which will save the values entered by… Read More »

## C007 An interactive C program to check whether a given number is a perfect number or not

A positive number is called Perfect Number if it is equal to the sum of all of its positive divisors,  excluding number itself. Let’s identify variables needed for this program. First variable will be the one which will save the value entered by the user and it will be NUM. Second variable will be i… Read More »