Tag Archives: function

C029 A C program with a function that returns the minimum and the maximum value in an array of integers

void minmax(int array[],int length,int *min,int *max); //prototype Let’s identify variables needed for this program. In this program, we need several variables to store array of decimal numbers and count the length of array and store minimum and maximum of the array. First variable will be the one which will save the list of integers in… Read More »

C028 A C program with a function that will return the length of a character string without using inbuilt function

Let’s identify variables needed for this program. In this program, we need several variables to store string and count the number of characters in the given string. First variable will be the one which will save the string entered by the user and it will be S[50]. In C language we do not have string… Read More »

C023 A C program to convert a given lowercase string to uppercase string without using the inbuilt string function

Explanation of FUNCTION: A function is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required. Function groups a number of program statements into a unit and gives it a name. This… Read More »

A C Program to replace a character in a String Using Function – IGNOU MCA Assignment 2013

MASTER OF COMPUTER APPLICATIONS Course Code : MCS-011 Course Title : Problem Solving and Programming Assignment Number : MCA(1)/011/Assign/13 Assignment 2013    A C program function strreplace(s, chr, repl_chr) which will replace each occurrences of character chr with the character repl_chr in the string s. The function returns the number of replacements. Place the source… 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 »