0% found this document useful (0 votes)
10 views

C Projects

This document contains programs for various C programming concepts and tasks. It includes programs to add, subtract, multiply and divide numbers, calculate simple and compound interest, check data types sizes, check if a number is a vowel or consonant, convert seconds to minutes and seconds, design a simple calculator, check for a leap year, convert decimal to binary, find the maximum of three numbers, and more.

Uploaded by

hunain.ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

C Projects

This document contains programs for various C programming concepts and tasks. It includes programs to add, subtract, multiply and divide numbers, calculate simple and compound interest, check data types sizes, check if a number is a vowel or consonant, convert seconds to minutes and seconds, design a simple calculator, check for a leap year, convert decimal to binary, find the maximum of three numbers, and more.

Uploaded by

hunain.ahmad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 59

C-Programming Lab

M.Sc. Banking and Financial


Analytics.

Submitted to:
Dr. Malik Nadeem

Hunain Ahmad
Roll No: 13
ID: 202304954
Content.
1 - Print welcome to C programming & Welcome to Jamia
2 - Program to add two number
3 - Program to add, subtract, multiply & divide two number
4 - Program to find the product of two long integer
5 - Program to calculate the power of the two number.
6 - Write a program to calculate the simple Interest.
7 - Write a program to calculate the Compound Interest.
8 - Print the size of various data types.
9 - Program to Dividing a float number.
10 - Write a program to check whether input alphabet is
consonant or a vowel.
11 - Writer a program that asks the user to enter the seconds and
then converts that value to minute and second. Example 130
second=2min 10sec.
12 - Write a program to design a simple calculator.
13 - Write a program of leap year.
14 - Write a program to covert decimal into binary number.
15 - Write a program that reads in three numbers and find the
maximum and next maximum.
16 - Write a program to reverse the digit in number.
17 - Program to find the GCD of two number.
18 - Program to find the GCD and LCM of two number.
19 - Program to write a table of any number given by the user
using a for loop.
20 - Program for printing the pyramid using (*).
21 -Program to make ASCII art.
22 - Program to print alphabet in a pattern of pyramid.
23 - Program to make a number table of 5.
24 - Write a program to check whether a number is prime or not.
25 - Write a program to check whether a number is prime or not
using function.
26 - Write a program to swap two numbers.
27 - Write a program for getting all three-digit Armstrong
numbers.
28 - Write a program to check whether a number is an Armstrong
number or not.
29 - Write a program to get the Fibonacci series using recursion.
30 - Write a program to get the factorial of a number using
recursion.
31 - Write a program to reverse a string.
32 - Write a program for calculating the area and circumference
of a circle.
33 - Write a program to find the mean variance and standard
deviation.
34 - Write a program for calculating 7 subject percentages using
an array.
35 - Write a program to find the maximum number using call by
function.
36 - Write a program to find the maximum number using while
loop.
37 - Write a program for sum of two number using while.
38 - Write a program to find the maximum number using a
function.
39 - Write a program to find out if a string is a palindrome.
40 - Make a structure of Employee names, genders, ages and
positions.
41 - Make a structure for the book’s name, pages, position and
price.
42 - Write a program for writing something in file.
43. Programme to convert decimal to binary using itoa function
44. Programme to generate ASCII symbols of from 0 to 225
45. Programme to generate a matrix.
46-Programme to Add and Subtract two matrices
Q.1 - Print welcome to C programming & Welcome to Jamia.
Answer

// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
int main()
{

printf("Welcome to c programming\n");
printf("Welcome to c jamia");

return 0;

}
Q.2 -Program to add two number.
Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>

int main()
{
int a,b,c;

printf("Enter two numbers you want to add \n");

scanf("%d%d",&a,&b);
c=a+b;
printf("Addition of given number = %d",c);
return 0;
}
Q.3 - Program to add, subtract, multiply & divide two number.
Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>

int main()
{
float a,b;
printf("Enter two numbers \n");
scanf("%f%f",&a,&b);
printf("The addition of two no. is = %f\n",a+b);
printf("The substraction of two no. is =%f\n",a-b);
printf("The multiplication of two no. is = %f\n",a*b);
printf("The division of two no. is = %f",a/b);
return 0;
}
Q.4 - Program to find the product of two long integer.
Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>
#include <math.h>

int main()
{
long int a,b,c;
printf("Enter two numbers \n");
scanf("%ld%ld",&a,&b);

printf("The multiplication of two no. is = %ld",a*b);


return 0;

}
Q.5 - Program to calculate the power of the two number.
Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>
#include <math.h>

int main()
{
int a,b,c;
printf("Enter two numbers \n");
scanf("%d%d",&a,&b);
c=pow(a,b);
printf("The a^b of two no. is = %d",c);
return 0;

}
Q.6 - Write a program to calculate the simple Interest.
Answer
// Hunain Ahmad , student id :- 202304954

# include <stdio.h>
int main()
{
int principal, rate, time, Simpleinterest;

printf("Enter the principal: ");


scanf("%d", &principal);

printf("Enter the rate: ");


scanf("%d", &rate);

printf("Enter the time: ");


scanf("%d", &time);
Simpleinterest = (principal * rate * time)/100;
printf("The Simple interest is %d", Simpleinterest);

return 0;
}

Q.7 - Write a program to calculate the Compound Interest.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
#include <math.h>
int main()
{
float principle, rate, time, CI,amount;
printf("Enter principle amount: ");
scanf("%f", &principle);
printf("Enter time: ");
scanf("%f", &time);
printf("Enter rate: ");
scanf("%f", &rate);
amount = principle* (pow((1 + rate / 100), time));
CI=amount-principle;
printf("Compound Interest = %f\n", CI);
printf("the total amount is = %f",amount);
return 0;
}

Q.8 -Print the size of various data types.


Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
int main() {
printf("Size of int: %d bytes\n", sizeof(int));
printf("Size of float: %d bytes\n", sizeof(float));
printf("Size of double: %d bytes\n", sizeof(double));
printf("Size of char: %d byte\n", sizeof(char));

return 0;
}
Q.9 - Program to Dividing a float number.
Answer
// Hunain Ahmad , student id :- 202304954
#include<stdio.h>
int main() {
float a,b;
printf("Enter two number you want to divide\n");
scanf("%f%f",&a,&b);
printf("Division of two number is = %f",a/b);

return 0;
}
Q.10 - Write a program to check whether input alphabet is consonant or a
vowel.
Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>
int main() {
char c;
printf("Enter an alphabet: ");
scanf("%c", &c);
if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I'
|| c == 'O' || c == 'U')
printf("%c is a vowel.", c);
else
printf("%c is a consonant.", c);
return 0;
}
Q.11 - Writer a program that asks the user to enter the seconds and then
converts that value to minute and second. Example 130 second=2min 10sec.
Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>

int main() {
int sec, min, hours, rem;

printf("Enter time in seconds: ");


scanf("%d", &sec);

hours = sec / 3600;


rem = sec % 3600;
min = rem / 60;
sec = rem % 60;

printf("Time in hours: %d\n", hours);


printf("Time in minutes: %d\n", min);
printf("Time in seconds: %d\n", sec);

return 0;
}

Q.12 - Write a program to design a simple calculator.


Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>
#include <math.h>
int main() {

char c;
float a,b;
printf("Enter an operator (+, -, *, /,^): ");
scanf("%c", &c);
printf("Enter two operands: \n");
scanf("%f %f", &a, &b);

switch (c)
{
case '+':
printf("%f + %f = %f",a,b,a + b);
break;
case '-':
printf("%f - %f = %f",a,b,a - b);
break;
case '*':
printf("%f * %f = %f",a,b,a * b);
break;
case '/':
printf("%f / %f = %f",a,b,a/b);
break;
case '^':
printf("%f ^ %f = %f",a,b,pow(a,b));
break;
default:
printf("Error! operator is not correct");
}

return 0;
}
Q.13 - Write a program to find a leap year.
Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
void main() {
char choice = 'y';
int year;
while (choice=='y'||choice=='Y') {
printf("Enter the year that you want to check: ");
scanf("%d", &year);
if ((year%400==0) || ((year%100!=0) && (year%4==0)))
{
printf("%d is a leap year\n", year);
}
else
{
printf("%d is not a leap year\n", year);
}
printf("Do you want to check another year? (y/n): ");
scanf(" %c", &choice);
}
}

Q.14 -write a program to covert decimal into binary number.


Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>

void main()
{
long int dec,bin=0;
int rem , i=1;
printf("Enter decimal number:");
scanf("%ld",&dec);
while(dec!=0)
{
rem=dec%2;
dec=dec/2;
bin=bin+rem*i;
i=i*10;
}
printf("Binary number is: %ld",bin);
}

Q.15 - write a program that reads in three numbers and find the maximum
and next maximum.
Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>

void main() {

float a,b,c;
printf("Enter the value of the numbers that you want to compare:\n");
scanf("%f%f%f",&a,&b,&c);
if((a>b)&&(a>c))
{
printf("The max value is %f",a);
if(b>c)
{
printf("The next max value is %f",b);
}
else{
printf("The next max value is %f",c);
}
}
else if((b>a)&&(b>c))
{
printf("The max value is %f",b);
if(a>c)
{
printf("The next max value is %f",a);
}
else{
printf("The next max value is %f",c);
}
}
else if((c>a)&&(c>b))
{
printf("The max value is %f",c);
if(a>b)
{
printf("The next max value is %f",a);
}
else{
printf("The next max value is %f",b);
}
}
}

Q.16 - Write a program to reverse the digit in number.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
void main()
{
long int n, reverse=0, rem;
printf("Enter a number: ");
scanf("%ld", &n);
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n=n/10;
}
printf("Reversed Number: %ld",reverse);
}

Q.17 - Program to find the GCD of two number.


Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>

int main(){
int a,b,x,y;
printf("Enter any two no.:\n");
scanf("%d%d",&x,&y);
a=x;
b=y;
while(x!=y){
if(x>y){
x=x-y;
}
else{
y=y-x;
}
}
printf("the GCD is %d\n",x);
}

Q.18- Program to find the GCD and LCM of two number.


Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>

int main(){
int a,b,x,y,LCM;
printf("Enter any two no.:\n");
scanf("%d%d",&x,&y);
a=x;
b=y;
while(x!=y){
if(x>y){
x=x-y;
}
else{
y=y-x;
}
}
printf("The GCD is %d\n",x);
LCM=(a*b)/x;
printf("The LCM is %d",LCM);
}

Q.19 - Program to write a table of any number given by the user using a for
loop.
Answer
// Hunain Ahmad , student id :- 202304954
#include<stdio.h>
void main(){

int a,w,i;
printf("enter the number that you want the table of:");
scanf("%d",&i);
for(a=1;a<=10;a++)
{
w=a*i;
printf("%d*%d=%d\n",i,a,w);
}
}

Q.20 - Program for printing the pyramid using (*).


Answer
// Hunain Ahmad , student id :- 202304954
#include<stdio.h>
void main()
{
int i,j;

for(i=5;i>=1;i--)
{
for(j=i;j<=5;j++)
{
printf("*");
}
printf("\n");
}

Q.21 –program to make ASCII art.


Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>
int main()
{
printf(R"EOF(
_,--', _._.--._____
.--.--';_'-.', ";_ _.,-'
.'--'. _.' {`'-;_ .-.>.'
'-:_ ) / `' '=.
)> {_/, /~)
snd |/ `^ .'
)EOF");
}

Q.22 - Program to print alphabet in a pattern of pyramid.


Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
void main(){

int a,w,i;
char c='A';
for(a=1;a<=5;a++)
{
for(i=1;i<=a;i++)
{
printf("%c",c);
}
c++;
printf("\n");
}

Q.23-program to make a number table of 5.


Answer
// Hunain Ahmad , student id :- 202304954
#include<stdio.h>
void main(){

int a,w;
for(a=1;a<=10;a++)
{
w=a*5;
printf("5*%d=%d\n",a,w);
}

}
Q.24-Program to check whether a number is prime or not.
Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
void main()
{
int i, num;
printf("Enter any number to Check for Prime: ");
scanf("%d", &num);
for (i = 2; i <= num-1; i++)
{
if (num % i == 0)
{
printf("%d is not a Prime number", num);
break;
}
}
if (i==num)
{
printf("%d is a Prime number", num);
}
}

Q.25- Program to check whether a number is prime or not


using function.
Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>
void isprime(int);
void main()
{
int a;
printf("Enter the number:\n");
scanf("%d",&a);
isprime(a);
}

void isprime(int x)
{
int i;
for(i=2;i<=x-1;i++)
{
if(x%i==0)
{
printf("not prime\n");
break;
}
}
if(i==x)
{
printf(" prime no.\n");
}
}

Q.26- Program to swap two numbers.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
void main()
{
int a, b;
printf("Enter values for a and b: \n");
scanf("%d %d", &a, &b);
a=a+b;
b=a-b;
a=a-b;
printf("After Swapping:\n");
printf("a = %d\nb = %d\n", a, b);
}

Q.27- Write a program for getting all three-digit Armstrong numbers.


Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
void main()
{
int num, i, rem, sum;
for (i = 100; i <= 999; i++)
{
num = i;
sum = 0;
while (num > 0)
{
rem = num % 10;
sum = sum + (rem * rem * rem);
num = num / 10;
}
if (i == sum)
{
printf("%d is an Armstrong number\n", i);
}
}}

Q.28- Program to check whether a number is an Armstrong number or not.


Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
void main ()
{
int n,arm=0,r,c;
printf("Enter the value:\n");
scanf("%d",&n);
c=n;
while (n>0)
{
r=n%10;
arm=(r*r*r)+arm;
n=n/10;
}
if(c==arm)
printf("Amstrong number");
else
printf("Not an armstrong number");
}

Q.29- Program to get the Fibonacci series using recursion.


Answer

// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
int fib(int n)
{
if(n==0)
return(0);
else if (n==1)
return(1);
else
return(fib(n-1)+fib(n-2));
}
int main()
{ int n,y,i;
printf("Enter the term:\n");
scanf("%d",&n);
for (i=0;i<=n-1;i++)
{
y=fib(i);
printf("%d\t",y);
}}

Q.30- Program to get the factorial of a number using recursion.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
int rec(int n);
int main()
{
int a, fact;
printf("Enter any number: ");
scanf("%d", &a);
fact = rec(a);
printf("Factorial is %d", fact);
return 0;
}
int rec(int n)
{
if (n == 0 || n == 1) {
return 1;
} else {
return n * rec(n - 1);
}
}

Q.31- Program to reverse a string.


Answer

// Hunain Ahmad , student id :- 202304954


#include<stdio.h>
#include<string.h>
void main()
{
char str[60];
int len, i;
printf("Program in C for reversing a given string ");
printf("\nPlease insert the string you want to reverse: ");
scanf( "%s", str);
len = strlen(str);
for(i = len - 1; i >= 0; i--) {
printf("%c", str[i]);
}
}

Q.32- Program for calculating the area and circumference of a circle.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
#define pi 3.1459
float area_circle(float r)
{
float area;
area = pi*r*r;
return area;
}
float circum_circle(float r)
{
float circum;
circum = 2*pi*r;
return circum;
}
int main()
{
float radius, area, circum;
printf("Enter the radius\n");
scanf("%f", &radius);
area = area_circle(radius);
circum = circum_circle(radius);
printf("The area of circle is: %f\n", area);
printf("The circumference of circle is: %f\n", circum);
return 0;
}
Q.33- Program to find the mean variance and standard deviation.
Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
#include<math.h>
int main()
{
float
arr[26]={15,16,15,17,15,18,15,19,15,20,15,21,15,22,15,23,15,24,15,25,23,24,2
1,22,26,45};
float sum;
float mean;
float variance;
float deviation;
int i;
for(i=0;i<26;i++)
sum=sum + arr[i];
mean=sum/25;
sum=0;
for (i=0;i<26;i++)
{
sum=sum+pow((arr[i] - mean),2);
}
variance = sum/26;
deviation = sqrt(variance);
printf("Mean of element : %f\n",mean);
printf("Variance of element : %f\n",variance);
printf("Standard deviation of element : %f\n",deviation);
return 0;
}
Q.34- Program for calculating 7 subject percentages using an array.
Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
int main()
{
float marks[7];
float sum=0,per;
int i;
for (i=0;i<=6;i++)
{
printf("Enter the marks for subject number %d: ",i+1);
scanf("%f",&marks[i]);
sum=sum+marks[i];
}
per=(sum/700)*100;
printf("The percentage is :%f",per);
}

Q.35- Program to find the maximum number using call by function.


Answer

// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
int max(int a , int b)
{
if(a>b)
printf("max number is %d",a);
else
printf("max number is %d",b);
}
int main()
{
int a,b;
printf("Enter the two numbers:\n");
scanf("%d%d",&a,&b);
max(a,b);
}

Q.36- Program to find the maximum number using call by function.


Answer

// Hunain Ahmad , student id :- 202304954


#include <stdio.h>
void main()
{
int a,b,c;
printf("Enter two numbers,q to quit\n");
while(scanf("%d%d",&a,&b))
{
if(a>b)
printf("Max number is A: %d\n",a);
else
printf("Max number is B: %d\n",b);
printf("Enter two numbers,q to quit\n");
}
}

Q.37- Program for sum of two number using while.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
void main()
{
int a,b,c;
printf("Enter two numbers,q to quit\n");
while(scanf("%d%d",&b,&c))
{
a=b+c;
printf("\nsum of numbers is %d",a);
printf("\nEnter two numbers,q to quit\n");
}

Q.38- Program to find the maximum number using a function.


Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
check_max(int a, int b)
{
if(a>b)
printf("The maximum number is %d",a);
else
printf("The maximum number is %d",b);
}
void main()
{
int a,b;
printf("Enter the two numbers: \n");
scanf("%d%d",&a,&b);
check_max(a,b);
}

Q.39- Program to find out if a string is a palindrome.


Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[100];
int i, len, flag;
flag = 0;
printf("\n Please Enter any String : ");
scanf("%s",str);
len = strlen(str);
for(i = 0; i < len; i++)
{
if(str[i] != str[len - i - 1])
{
flag = 1;
break;
}
}
if(flag == 0)
{
printf("\n %s is a Palindrome String", str);
}
else
{
printf("\n %s is Not a Palindrome String", str);
}
return 0;
}
Q.40- Make a structure of employee names, genders, ages and positions.
Answer
// Hunain Ahmad , student id :- 202304954
#include <stdio.h>
struct employee
{
char name[15];
char gender[15];
int age;
char position[15];
};
int main()
{
int i;
struct employee e[5];
for (i = 0; i < 2; i++)
{
printf("Enter name, age, position, and gender for employee %d: \n", i + 1);
scanf("%s %d %s %s", e[i].name, &e[i].age, e[i].position, e[i].gender);
}
printf("\nEmployee details:\n");
for (i = 0; i < 2; i++)
{
printf("%s %d %s %s\n", e[i].name, e[i].age, e[i].position, e[i].gender);
}
return 0;
}
Q.41- Make a structure for the book’s name, pages, position and price.
Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
struct book
{
char name[15];
int page;
char position[10];
float price;
};
int main()
{
int i;
struct book b[5];
for (i = 0; i < 2; i++)
{
printf("Enter the name, page, position, and price of the book %d: \n", i +
1);
scanf("%s %d %s %f", b[i].name, &b[i].page, b[i].position, &b[i].price);
}
printf("\nBook's details:\n");
for (i = 0; i < 2; i++)
{
printf("%s %d %s %.2f\n", b[i].name, b[i].page, b[i].position, b[i].price);
}
return 0;
}
Q.42- Program for writing something in file.
Answer
// Hunain Ahmad , student id :- 202304954

#include<stdio.h>
#include<stdlib.h>
int main()
{
int num;
FILE *ptr;
if((ptr=fopen("C:/SID/Asus/Desktop/content.txt","w"))==NULL)
{
printf("Error in opening file ");
exit(1);
}
printf("enter any value to write on the file");
scanf("%d",&num);
fprintf(ptr,"%d",num);
fclose(ptr);
return 0;
}

Q.43. Programme to convert decimal to binary using itoa function

// Hunain Ahmad , student id :- 202304954

#include <stdio.h>
int main(){
int a;
char c[50];
printf("enter the number you want to cuonvert into some sort:");
scanf("%d",&a);
itoa(a,c,2);
printf("%s",c);
}
Q.44. Programme to generate ASCII symbols of from 0 to 225
Answer
// Hunain Ahmad , student id :- 202304954

#include <stdio.h>

void main() {
int i;
for(i=0;i<=255;i++){
printf("%c\t%d\n",i,i);
}

}
Q.45. Programme to generate a matrix.
Answer:

#include<stdio.h>
void main(){
int a[3][4],b[3][4];
int i,j;
for(i=0;i<=2;i++){
for(j=0;j<=3;j++){
scanf("%d",&a[i][j]);
}
}
for(i=0;i<=2;i++){
printf("\n");
for(j=0;j<=3;j++){
printf("%d\t",a[i][j]);
}
}

}
Q.46. Programme to Add and Subtract two matrices
Answer:

#include<stdio.h>
void main(){
int a[3][4],b[3][4];
int i,j;
printf("Enter the values of the 1st matrix(12 values)\n");
for(i=0;i<=2;i++){
for(j=0;j<=3;j++){
scanf("%d",&a[i][j]);
}
}
printf("The 1st matrix is:\n");
for(i=0;i<=2;i++){
printf("\n");
for(j=0;j<=3;j++){
printf("%d\t",a[i][j]);
}
}

printf("\nEnter the values of the 2nd matrix(12 values)\n");


for(i=0;i<=2;i++){
for(j=0;j<=3;j++){
scanf("%d",&b[i][j]);
}
}

printf("The 2nd matrix is:\n");


for(i=0;i<=2;i++){
printf("\n");
for(j=0;j<=3;j++){
printf("%d\t",b[i][j]);
}
}
printf("\nThe sum of the two matrix:\n");
for(i=0;i<=2;i++){
printf("\n");
for(j=0;j<=3;j++){
printf("%d\t",a[i][j]+b[i][j]);
}
}
printf("\nThe substraction of the two matrix:\n");
for(i=0;i<=2;i++){
printf("\n");
for(j=0;j<=3;j++){
printf("%d\t",a[i][j]-b[i][j]);
}
}
}

You might also like