C Model Question Papers for BCA 1st year Kannur Bharathiar MG Madras Bangalore University

C Model Question Papers for BCA 1st year Kannur Bharathiar MG Madras Bangalore University :
Fist Year BCA Model Question Paper for C Programming Language :-

Model Question Paper
B.C.A. : I Year: Programming using C: Time: 3 Hrs.
Max. Marks: 100

SECTION – A
1) Answer the following Questions : 10 x 2 = 20 M
a) Define Algorithm.
b) Define Identifier.
c) What is the Purpose of sizeof() operator.
d) Compare while and do-while loops. Justify your answer.
e) Define Recursion.
f) How can we initialize an array.
g) What is the difference between structure and union ?
h) Define Pointer variable.
i) Define Macro.
j) What is the purpose of rewind() function.

Section – B
Answer the following questions. 4 x 20 = 80 M
2. a) Explain the structure of C program.
b) Explain features of C language.
(or)
c) Describe in brief the operators in C language.
d) Write a C program to evaluate the following expression.
(a+(b*c)/d)
3. a) Explain control structures with examples.
(or)
b) Explain different parameter passing techniques.
c) Write a program to calculate factorial of given number using
Recursion.
4. a) Define array. Write a C program to sort elements of array
in ascending order.
b) Explain string manipulation function with examples.
(or)
c) How can we pass strings as arguments to functions.
d) Explain Nested structures with examples.
5. a) Explain Pointer Arithmetic with examples.
b) Write a C program to access array elements using Pointers.
(or)
c) Explain different file modes available in C language.
c) Describe in brief about Random Access Files

Reverse Digits of a Number in C Program, Number Reverse using Recursion or Array in C Program

Reverse Digits of a Number in C Program, Number Reverse using Recursion or Array in C Program :

Example : Write a C program to reverse the digits of a Number.

#include<stdio.h>
#include<conio.h>

void main()
{
int n,rem,reverse_number=0;
clrscr();
printf("Enter an integer number to be reversed :");
scanf("%d",&n);
while ( n != 0 )
{
rem = n % 10 ;
n = n / 10 ;
reverse_number = ( reverse_number * 10 ) + rem ;
}
printf("Reverse Number is %d\n",reverse_number);
getch();
}


Example : c program to reverse the digits of a number using recursion.

#include<stdio.h>
#include<conio.h>


void reverse_Number(int);
void main()
{
int num ;
clrscr();
printf("Enter number : ");
scanf("%d", & num);
printf("\nNumber Reverse = ");
reverse_Number(num);
getch();
}

void reverse_Number(int num)
{
if ( num > 0 )
{
printf( "%d" , num%10 ) ;
reverse_Number(num/10);
}
}


Example : Write a C program to reverse digits of a number using integer Array.

#include<stdio.h>
#include<conio.h>

void main()
{
int n , rem , reverse_number[5] , i , j ;
clrscr();

printf("Enter a number[max 5 digits] to be reversed :");
scanf( "%d" , &n ) ;

for ( i = 0 ; n != 0 ; i++ )
{
rem = n % 10 ;
reverse_number [ i ] = rem ;
n = n / 10 ;
}

printf("Reverse Number is = ");
for ( j = 0 ; j < i ; j++ )
{
printf("%d",reverse_number[j]);
}

getch();
}


C Code Shortening Techniques or My Logic for Reduced Source Code Writing in C Program Language

C Code Shortening Techniques or My Logic for Reduced Source Code Writing Tips and Tricks in C Program Language :-


Perhaps, you might have heard that the for() loop should not end with ";" like if(). But, in fact the ";" is using in C language as a Statement Terminator, so, if we want to terminate for() loop, then we should use ";" at the end of for() loop.

[ Header files are to be included as usual, it is not written in the examples ]

Question : write a C program to print 1 to 10 numbers using for() loop ?

Example 1 :

void main()
{
int i;
for ( i = 1 ; i <= 10 ; i++ )
{
printf("%d\n",i);
}
}

/* above program, for() loop has one statement outside, so we do not use ";" at the end, because if we put ";" the for() will not take the continuing statement as its own. */

Example 2 :

void main()
{
int i;
for ( i = 1 ; i <= 10 ; printf( "%d \n" , i ) , i++ ) ;
}

/* above program, for() loop has one statement inside, so we use ";" at the end, because the for() will run self contained statement as its own. */

Question : whether the left "{" and right "}" are needed any Looping(for(), while() etc) and Selection(if(), switch() etc) statements ?

Example 1 : see the program structure only, and not to run.

for ( i = 1 ; i <= 5 ; i++ )
{
for ( j = 1 ; j <= 5 ; j++ )
{
if ( i == j )
{
printf( "%d\n" , i ) ;
}
}
}

Example 1 : same as above can also be written in the following.

for ( i = 1 ; i <= 5 ; i++ )
for ( j = 1 ; j <= 5 ; j++ )
if ( i == j )
printf( "%d\n" , i ) ;
because this all statement has one statement only, so we do not need to use "{" and "}". first for() has another one for() then this for() has only one if() and the if() has only one printf(). That is each statement will take the continuing statement as its own with out using "{" and "}" and if any statement has more than one statements should use "{" and "}".


Insertion Sort in C Program with Algorithm and Function Code Reducing Techniques

Insertion Sort in C Program with Algorithm and Function Code Reducing Techniques :

Example for Insertion Sorting in C Language Program with Explanations is given below :-
Every repetition of insertion sort removes an element from the input data, inserting it into the correct position in the already-sorted list, until no input elements remain. The choice of which element to remove from the input is arbitrary, and can be made using almost any choice algorithm.
Sorting is typically done in-place. The resulting array after k iterations has the property where the first k + 1 entries are sorted. In each iteration the first remaining entry of the input is removed, inserted into the result at the correct position, thus extending the result:

#include<stdio.h>
#include<conio.h>

void insertion_Sort(int, int []); /* function prototype declaration */

void main()
{
int arr[100] , a , n ;
clrscr();
printf("Enter the number of array elements to be Sorted :");
scanf( "%d" , &n );

printf("\nEnter the array elements :\n");
for( a = 0 ; a < n ; scanf("\n %d",&arr[a]) , a++ ); /* see help below */
insertion_Sort(n,arr); /* function calls here. n means array length and arr means array name its enough while passing array */

printf("\nSorted array is given below :");

for( a = 0 ; a < n ; printf(" \n%d " , arr[a] ) , a++ ) ;

/* use ; to end loop, as it contains one statement inside. if we use printf() out side for() loop as usual, then do not use ; at the end of for() loop */

getch();
}

// main() ends here

void insertion_Sort(int n, int arr[]) /* UDF defines here */
{
int i , temp , j ;
for( i = 1 ; i < n ; i++ )
{
temp = arr[i];
j = i - 1 ;
while( j >= 0 )
{
if( temp <= arr[j] )
{
arr[j+1] = arr[j] ;
arr[j] = temp ;
}
j = j - 1 ;
}

}
}

/* below function is same as above, but the program code has been reduced. if you understand, you can use it instead of above function code :

void insertion_Sort(int n, int arr[])
{
int i , temp , j ;
for( i = 1 ; i < n ; i++ )
for( j = i - 1 , temp = arr[i] ; j >= 0 ; j-- )
if( temp <= arr[j] )
{
arr[j+1] = arr[j] ;
arr[j] = temp ;
}

}
*/

Quick Sort in C Code with Algorithm using Recursion and Code Reducing Techniques

Quick Sort in C Code with Algorithm using Recursion and Code Reducing Techniques :

Example for Quick Sort Program in C using Recursion with Algorithm is given below :-

Quicksort is a divide and conquer algorithm. Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quicksort can then recursively sort the sub-lists. Pick an element, called a pivot, from the list. Reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation. Recursively sort the sub-list of lesser elements and the sub-list of greater elements. The base case of the recursion are lists of size zero or one, which never need to be sorted.

#include<stdio.h>
#include<conio.h>

void quick_Sort( int [], int, int ); /* function prototype declaration */

void main()
{
int a[ 100 ], n, i;
clrscr();

printf( "Enter the Number array elements to be sorted :" );
scanf( "%d", &n );

printf( "Enter array elements :\n" );
for ( i = 0; i < n ; scanf( "%d", &a[ i ] ), i++ ); /* use ; to end FOR LOOP, as one statement contains inside the LOOP */
quick_Sort( a, 0, n – 1 ); /* UDF calls here */

printf( "The Sorted Array is given below\n" );
for ( i = 0 ; i < n ; printf( "%d\t", a[ i ] ), i++ ); /* did as above, printf() can also be put out side FOR LOOP as usual */
getch();
}
void quick_Sort( int a[], int low, int high ) /* UDF defines here */
{
int l, h, key, temp, t;
key = a[ low ];
l = low;
h = high;
while ( low < high )
{
if ( a[ low ] < key )
{
low = low + 1;
}
else
{
if ( a[ high ] > key )
{
high = high – 1;
}
else
{
temp = a[ low ];
a[ low ] = a[ high ];
a[ high ] = temp;
}
}
}
t = key;
key = a[ high ];
a[ high ] = t;
if ( l < high )
{
quick_Sort( a, 0, high – 1 );
}
if ( low < h )
{
quick_Sort( a, high + 1, n – 1 );
}
}

C Palindrome String using Pointers Example, C Program to find String Palindrome or not.

C Program for Palindrome String using Pointers Example, C Program to find String Palindrome or not?

Example : Write a Program to print a String Palindrome or not in C Language is given below:-

#include<stdio.h>
#include<conio.h>
#include<string.h>

int string_Palindrome(char* str)
{
int i,len;
len = strlen(str);
for( i = 0 ; i < len / 2 ; i++ )
{
if( *(str + i ) != *(str + len - i - 1) )
return 0;
}
return 1;
}
void main()
{
char string[100]="";
clrscr();
printf("Enter a string :");
gets(string);
if( string_Palindrome(string))
printf("\n%s is a palindrome",string);
else
printf("\n%s is not a palindrome",string);
getch();
}

Binary Search use Recursion in C or C Program for Binary Search using Array Passing UDF

Binary Search using Recursion function in C or C Program for Binary Search using Array Passing User Defined Function :-

Example : How to write C Program for Binary Search using Recursive Function and its solutions given below :-

#include<stdio.h>
#include<conio.h>

int binarySearch(int lmt[],int arrayStart,int arrayEnd,int a) /* UDF declar with definition */
{
int m,pos;
if (arrayStart<=arrayEnd)
{
m=(arrayStart+arrayEnd)/2;
if (lmt[m]==a)
return m;
else if ( a < lmt[m] )
return binarySearch(lmt,arrayStart,m-1,a); /* function calls itself called Recursive function */
else
return binarySearch(lmt,m+1,arrayEnd,a); /* function calls itself called Recursive function */
}
return -1;
}

void readArray(int lmt[],int n) /* UDF declar with definition */
{
int i;
printf("Enter the array elements :\n");
for( i=0 ; i < n ; i++ )
scanf("%d",&lmt[i]);
}

/* main() function starts here */
void main()
{

int lmt[10], num, searchElement,pos;

clrscr();


printf("Enter the number of array elements to be printed :");
scanf("%d",&num);

readArray(lmt,num);

printf("\nEnter the element you want to search :");
scanf("%d",&searchElement);

pos=binarySearch(lmt,0,num,searchElement);
if(pos==-1)
{
printf("\nElement not found");
}
else
{
printf("\nElement found at %d position",++pos);
}

getch();
}
/*
if we give no of elements is 5 and array elements are 11,22,33,66,45 then element to be searched is 66 then answer will be "Element found at 4 position" otherwise "Element not found"
*/

C Program for Bubble Sort Example, C Bubble Sort integer Array, Bubble Sort Program in C Language

C Program for Bubble Sort Example, C Bubble Sort integer Array, Bubble Sort Program in C Language :-

Example - Bubble Sort Program in C for integer Array with maximum 100 elements and the source is given below :-

#include<stdio.h>
#include<conio.h>

void main( )
{
int arr[100], i, j, n, temp ;
clrscr();

printf("Enter the number of elements to be sorted :");
scanf("%d",&n);

printf("\nEnter the integer elements :\n");

for(i=0 ; i<n ; scanf("%d",&arr[i]), i++); /* here for() loop ended with ; and scanf() can also be put out side for() as we use regular */
n=n-2;
for ( i = 0 ; i <= n ; i++ )
{
for ( j = 0 ; j <= n - i ; j++ )
{
if ( arr[j] > arr[j + 1] )
{
temp = arr[j] ;
arr[j] = arr[j + 1] ;
arr[j + 1] = temp ;
}
}
}

printf ( "\nArray after sorting:\n");

n++;

for ( i = 0 ; i <= n ; i++ )
printf ( "%d,", arr[i] );

getch();
}

/*

if we give no of elements as 5 and elements are 23,4,77,45,3 then output will be as below:
3,4,23,45,77

*/

C Program to find Fibonacci Series, Fibonacci Series using Recursion Function in C

C Program to find Fibonacci Series, Fibonacci Series using Recursion Function in C :

Example 1 : How to Write Fibonacci Series using Recursion Function in C with easy logic is given below :-

#include<stdio.h>
#include<conio.h>

fibonacciSeries(int);
void main()
{
int n,r,i;
clrscr();
printf("Enter the number of elements to be printed in Fibonacci Series :");
scanf("%d",&n);
printf("\n");
for(i=0 ; i < n ; i++)
{
r=fibonacciSeries(i);
printf("%d,",r);
}
getch();
}

fibonacciSeries(int n)
{
int f;
if((n==1)||(n==2))
return(1);
else if(n==0)
return(0);
else
f=fibonacciSeries(n-2)+fibonacciSeries(n-1);
return(f);
}

/* if enter 7 then output will be 0,1,1,2,3,5,8, */

Example 2 : How to Write Fibonacci Series in C upto a limit is given below :-

#include<stdio.h>
#include<conio.h>

void main()
{
int n,a=0,b=1,c=0;
clrscr();
printf("Enter a limit :");
scanf("%d",&n);
printf("\n");
for( ;c <= n ; ) /* it means while(c <= n), here for loop does not have first and third part, so it was left blank thats all */
{
printf("%d,",c);
a=b;
b=c;
c=a+b;
}
getch();
}

/* if enter 7 then output will be 0,1,1,2,3,5, */

C Program to Convert Decimal to Binary, Easy Logic to Convert Decimal to Binary in C Language

C Program to Convert Decimal to Binary, Easy Logic to Convert Decimal to Binary in C Language :

Example : How to Convert Decimal Number to Binary in C with explanations given below :-

#include<stdio.h>
#include<conio.h>
void main()
{
int q[50],i,a,n,count=0;
clrscr();

printf("\nEnter a Decimal Number :");
scanf("%d",&n);

for(i=0 ; n>0 ; i++)
{
a = n%2; /* storing remainter part, eg a=7%2 then a=1 ie 3.1 */
q[i] = a;
n = n/2; /* storing integer part, eg a=7/2 then a=3 ie 3.1 */
count++;
}

printf("\nThe Conversion is given below :\n");

for(i=0 ; i < count ; i++)
printf("%d",q[i]);

getch();
}

/* if we enter a decimal number as 7 the result will be 111, if 5 then 101 */

C Program to find Prime Number using UDF, also find Prime Numbers upto a limit in C Language

C Program to find Prime Number using UDF, also find Prime Numbers upto a limit in C Language:

Example 1 : C Program to find prime number using user defined function :-

#include<stdio.h>
#include<conio.h>

int primeNumber(int); /* function declaration or prototype, int arg int returns */

void main()
{

int num,prime;
clrscr();

printf("Enter an integer Number :");
scanf("%d",&num);

prime = primeNumber(num); /* function call here with Actual Parameter num, rtns integer value and assigning to the var prime */

if(prime==1)
printf("%d is a prime number",num);
else
printf("%d is not a prime number",num);

getch();
}

int primeNumber(int n) /* function definition with Formal Parameter n and returns an integer */
{

int i;

for( i=2 ; i<=n/2 ; i++)
{
if(n%i==0)
return 0;
}

return 1;
}

/* prime number 3,7,11,17.... */

Example 2 : C Program to find prime numbers upto a limit using user defined function :-

#include<stdio.h>
#include<conio.h>

int primeNumber(int);

void main()
{

int num,lmt;
clrscr();

printf("Enter a limit :");
scanf("%d",&lmt);

for(num=3 ; num <= lmt ; num++)
{
if(primeNumber(num)==1)
{
printf("\n%d",num);
}
}
getch();
}

int primeNumber(int n)
{

int i;

for( i=2 ; i<=n/2 ; i++)
{
if(n%i==0)
return 0;
}

return 1;
}


How to create User Defined Functions in C, see example Perfect_Number() function used as UDF in C Program

How to create User Defined Functions in C, see example Perfect_Number() function used as UDF in C Program :-

Example : This is a program to find Perfect Numbers upto a limit using User Defined Function(UDF) in C Program Language :-

#include<stdio.h>
#include<conio.h>

int Perfect_Number(int); /* UDF function prototype declaration : int argument and int returns */

main()
{
int lmt,num;
clrscr();
printf("Enter a Limit :");
scanf("%d",&lmt);
for(num=5 ; num<=lmt ; num++)
{
/* function calls here with Actual Parameter num and returns either 1 or 0 and checks */
if(Perfect_Number(num)==1)
{
printf("\n%d",num);
}
}
getch();
}

/* Either the function should be defined out side the main() or it should be in one of the header files included. function definition with a Formal Parameter as n */

int Perfect_Number(int n)
{
int a,sm;
sm=0;
for(a=1 ; a<n ; a++)
{
if(n%a==0)
{
sm=sm+a;
}
}
if(sm==n)
return 1;
else
return 0;
}

/*
Run, and if we give limit as 500 then the output will be as below:
6
28
496
*/

Actual Parameter and Formal Parameters : Call by Value and Call by Reference

In computer programming, a parameter is a special kind of variable, used in a subroutine to refer to one of the pieces of data provided as input to the subroutine. These pieces of data are called arguments. An ordered list of parameters is usually included in the definition of a subroutine, so that, each time the subroutine is called, its arguments for that call can be assigned to the corresponding parameters.
Just as in standard mathematical usage, the argument is thus the actual value passed to a function, procedure, or routine, whereas the parameter is a reference to that value inside the implementation of the function.
In the most common case, call-by-value, a parameter acts within the subroutine as a local (isolated) copy of the argument, but in other cases, e.g. call-by-reference, the argument supplied by the caller can be affected by actions within the called subroutine.
The semantics for how parameters can be declared and how the arguments get passed to the parameters of subroutines are defined by the language, but the details of how this is represented in any particular computer system depend on the calling conventions of that system.


These two terms are sometimes loosely used interchangeably; in particular, "argument" is sometimes used in place of "parameter". Nevertheless, there is a difference. Properly, parameters appear in procedure definitions; arguments appear in procedure calls.
A parameter is an intrinsic property of the procedure, included in its definition. For example, in many languages, a minimal procedure to add two supplied integers together and calculate the sum total would need two parameters, one for each expected integer. In general, a procedure may be defined with any number of parameters, or no parameters at all. If a procedure has parameters, the part of its definition that specifies the parameters is called its parameter list.
By contrast, the arguments are the values actually supplied to the procedure when it is called. Unlike the parameters, which form an unchanging part of the procedure's definition, the arguments can, and often do, vary from call to call. Each time a procedure is called, the part of the procedure call that specifies the arguments is called the argument list.
Although parameters are also commonly referred to as arguments, arguments are more properly thought of as the actual values or references assigned to the parameter variables when the subroutine is called at run-time. When discussing code that is calling into a subroutine, any values or references passed into the subroutine are the arguments, and the place in the code where these values or references are given is the parameter list. When discussing the code inside the subroutine definition, the variables in the subroutine's parameter list are the parameters, while the values of the parameters at runtime are the arguments.
Many programmers use parameter and argument interchangeably, depending on context to distinguish the meaning. The term formal parameter refers to the variable as found in the function definition (parameter), while actual parameter refers to the actual value passed (argument).

How to Compile and Run CGI Scripts in C Examples in Linux Apache Server

How to Compile and Run CGI Scripts in C Examples in Linux Apache Server :-

first let us create an HTML file(testcgi.html) :
it can be made using keditor, geditor or vi editor


use form action http://localhost/cgi-bin/sum.cgi

then we have to make a C Program (sum.c):

#include<stdio.h>
#include<stdlib.h>

int main(void)
{
char *data;
long m,n;
printf("%s%c%c\n","Content-Type:text/html;charset=iso-8859-1",13,10);
printf("Result\n");
printf("HTML Form values are added...\n");
data = getenv("QUERY_STRING");
if(data == NULL)
printf("Error! Error in passing data from form to script.");
else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2)
printf("Error! Invalid data. Data must be numeric.");
else
printf("The Sum of %ld and %ld is %ld.",m,n,m+n);
return 0;
}

To Compile:
in linux login root user and go to command line terminal
root# cc sum.c -o sum.cgi
root# chmod 777 sum.cgi
root# cp sum.cgi /var/www/cgi-bin/
otherwise find cgi-bin directory and put it there.
then put html file some where
root# cp testcgi.html /var/www/html/

next run apache web server:
root# service httpd restart

then open a browser and give an address like
http://localhost/cgi-bin/testcgi.html

Enter two numbers and the result will be displayed in the next page.

How to create a Header File in C Language or In C How to make User Defined Header Files

How to create a Header File in C Language or In C How to make User Defined Header Files :-

First we have to install or copy Turbo C++ in our computer. If we copy the TC folder, which should be copied into the same Drive as the Source Computer Drive, otherwise an Error will occur see more.

Any way let us guess the C Program in "C:\TC\BIN\TC.EXE"

then usually the Header files residing in "C:\TC\INCLUDE\" directory.

our working directory is "C:\TC\BIN\"

Let us try How to create a "Hello World!" Program with clrscr() SDF :-

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();
printf("Hello World!");
}

in the above program, we used clrscr() as a System Defined Function, because it is defined in conio.h and it is included.

Let us try How to create a "Hello World!" Program with clrscr() as UDF and User Defined Header File :-

Step 1:
fist let us make a header file named "my_header_file.h" and its contents given below

#include<stdio.h>
#include<conio.h>
void clrscr(void)
{
int i;
gotoxy(1,1);
for(i=1;i<=25;i++)
{
printf("\n");
}
gotoxy(1,1);
}

save as in the location mentioned above "C:\TC\INCLUDE\my_header_file.h"

header file creation over

Step 2:

now create our C file named "my_c_file.c"

#include<stdio.h>
#include<my_header_file.h>
main()
{
clrscr();
printf("Hello World!");
}

save as in the location mentioned above "C:\TC\BIN\my_c_file.c"

in the above program, we used clrscr() as a User Defined Function, it is defined in the header file my_header_file.h and it is included instead of conio.h.

Now let us see the real thing. just Run "C:\TC\BIN\my_c_file.c"
output will be:

Hello World!

Note:

1) if we save our header in "C:\TC\INCLUDE\" it should be included as #include<my_header_file.h>

2) if we save our header in "C:\TC\BIN\" it should be included as #include"my_header_file.h"

C Program for Matrix Multiplication or Matrix Multiplication in C Example Source Code

C Program for Matrix Multiplication or Matrix Multiplication in C Example Source Code given below:

Matrix Multiplication Example 1 :-

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];
clrscr(); // first clear the screen

printf("Enter the number of rows and columns of first matrix\n");
scanf("%d%d",&m,&n);
printf("Enter the number of rows and columns of second matrix\n");
scanf("%d%d",&p,&q);
if ( n != p )
{
printf("Sorry! Matrix Multiplication can't be done, study row col combination of Matrices...\n");
getch(); // uses wait comand and in conio.h
exit(0); // to exit program and in stdlib.h
}
printf("Enter the elements of first matrix\n");
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
scanf("%d",&first[c][d]);
printf("Enter the elements of second matrix\n");
for ( c = 0 ; c < p ; c++ )
for ( d = 0 ; d < q ; d++ )
scanf("%d",&second[c][d]);
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
{
for ( k = 0 ; k < p ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
sum = 0;
}
}
printf("Product of entered matrices:-\n");
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
printf("%d\t",multiply[c][d]);
printf("\n");
}

getch();
return 0;
}

Matrix Multiplication Example 2 ( a few codes used here ) :-

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];
clrscr();

printf("Enter the number of rows and columns of first matrix\n");
scanf("%d%d",&m,&n);
printf("Enter the number of rows and columns of second matrix\n");
scanf("%d%d",&p,&q);
if ( n != p )
{
printf("Sorry! Matrix Multiplication can't be done, study row col combination of Matrices...\n");
getch(); // uses wait comand and in conio.h
exit(0); // to exit program and in stdlib.h
}
printf("Enter the elements of first matrix\n");
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
scanf("%d",&first[c][d]);
printf("Enter the elements of second matrix\n");
for ( c = 0 ; c < p ; c++ )
for ( d = 0 ; d < q ; d++ )
scanf("%d",&second[c][d]);

for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; multiply[c][d] = sum, sum = 0, d++ )
for ( k = 0 ; k < p ; sum = sum + first[c][k]*second[k][d], k++ ); /* for loop doesn't have other statements, so use ";" to end loop */
printf("Product of entered matrices:-\n");
for ( c = 0 ; c < m ; printf("\n"), c++ )
for ( d = 0 ; d < q ; printf("%d\t",multiply[c][d]), d++ ); /* for loop doesn't have other statements, so use ";" to end loop */
getch();
return 0;
}

How to Reverse a String in C without using C Reverse String function and using either Pointers or Recursive Function.

C Program to Reverse a String without using C Reverse String function (strrev() in string.h) and using either Pointers or Recursive Function is given below:-
1) C Example program to Reverse a String using pointers :

#include<stdio.h>
int strLength(char*); // user defined function declaration or function prototype
void strReverse(char*); // UDF declr or fun proto
main()
{
char str[100];
printf("Enter a String to be Reversed :");
gets(str); // using gets() instead of scanf() because scanf() does not take space char
strReverse(str); // function with argument as string variable str calls here
printf("Reverse of given String is \"%s\".\n", str);
return 0;
}
void strReverse(char *str) // strReverse() function defines here
{
int length, c;
char *begin, *end, temp;
length = strLength(str); // function strLength() calls here and which returns integer value to be stored in "length" variable.
begin = str;
end = str;
for ( c = 0 ; c < ( length - 1 ) ; c++ )
end++;
for ( c = 0 ; c < length/2 ; c++ )
{
temp = *end;
*end = *begin;
*begin = temp;
begin++;
end--;
}
}
int strLength(char *pointer) // strLength() function defines here, which returns an integer
{
int c = 0;
while( *(pointer+c) != '\0' )
c++;
return c;
}

2) C Example program to Reverse a String using Recursive Function ( function calls itself ) :

#include<stdio.h>
#include<string.h>
void strReverse(char*,int,int);
main()
{
char str[100];
printf("Enter a String to be Reversed :");
gets(str);
strReverse(str, 0, strlen(str)-1);
printf("Reverse of given String is \"%s\".\n", str);
return 0;
}
void strReverse(char *ch, int begin, int end)
{
char a, b, c;
if ( begin >= end )
return;
c = *(ch+begin);
*(ch+begin) = *(ch+end);
*(ch+end) = c;
strReverse(ch, ++begin, --end);
}