Simple Interest Calculation
Simple Interest Calculation
#include<stdio.h>
#include<conio.h>
void main()
{
float p,n,r,s;
clrscr();
printf("Enter the values of p,n and r");
scanf("%f%f%f",&p,&n,&r);
s=(p*n*r)/100;
printf("The Simple Interest is : %.2f",s);
}
RUN 1 :
~~~~~~~
Enter the values of p,n and r
5800
6
5.2
The Simple Interest is : 1809.59
else
printf("\nEquation is linear") ;
getch() ;
}
RUN 1 :
~~~~~~~
Enter the values of A, B & C : 0.0
4.0
7.0
Equation is linear
RUN 2 :
~~~~~~~
Enter the values of A, B & C : 1.0
2.0
7.0
2.0
1.0
7.0
1.0
153
370
371
407
Output:
***Temperature Conversion***
Enter the Celcius value : 37
The Converted Farenheit value : 98.599998
/* Factorial-Recursion*/
# include <stdio.h>
# include <conio.h>
void main()
{
int n;
long int f;
long int fact();
clrscr();
printf("\n\t***Factorial Of A Given Number***\n\n");
printf("Enter the number : ");
scanf("%d",&n);
f=fact(n);
printf("\nFactorial is : %ld",f);
getch();
}
long int fact(int n)
{
if (n==0)
return (1);
else
return (n*fact(n-1));
}
Output:
***Factorial Of A Given Number***
Enter the number : 6
Factorial is : 720
/*Matrix Multiplication*/
# include <stdio.h>
# include <conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10];
int i,j,k,r1,c1,r2,c2;
clrscr();
printf("\n\t\t***Matrix Multiplication***\n\n");
printf("Enter the order of Matrix A : ");
scanf("%d %d",&r1,&c1);
printf("\nEnter the Elements of A :\n");
for (i=0;i<r1;i++)
for (j=0;j<c1;j++)
scanf("%d",&a[i][j]);
printf("\n\nEnter the order of Matrix B : ");
scanf("%d %d",&r2,&c2);
printf("\nEnter the Elements of B :\n");
for (i=0;i<r2;i++)
for (j=0;j<c2;j++)
scanf("%d",&b[i][j]);
clrscr();
printf("\n\nMatrix A is :\n");
for (i=0;i<r1;i++)
{
for (j=0;j<c1;j++)
printf("%2d ",a[i][j]);
printf("\n");
}
printf("\n\nMatrix B is :\n");
for (i=0;i<r2;i++)
{
for (j=0;j<c2;j++)
printf("%2d ",b[i][j]);
printf("\n");
}
for (i=0;i<r1;i++)
for (j=0;j<c2;j++)
c[i][j]=0;
if (c1==r2)
{
for (i=0;i<r1;i++)
for (j=0;j<c2;j++)
for (k=0;k<c1;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
printf("\n\nProduct of A and B is :\n");
for (i=0;i<r1;i++)
{
for (j=0;j<c2;j++)
printf("%2d ",c[i][j]);
printf("\n");
}
}
else
printf("\n\nMultiplication is not possible");
getch();
}
Output:
***Matrix Multiplication***
Enter the order of Matrix A : 2 3
Enter the Elements of A :
2 4 3 1 5 6
Enter the order of Matrix B : 3 2
Enter the Elements of B :
1 5 4 6 3 4
Matrix A is :
2 4 3
1 5 6
Matrix B is :
1 5
4 6
3 4
Product of A and B is :
27 46
39 59
***Matrix Multiplication***
Enter the order of Matrix A : 2 3
Enter the Elements of A :
2 2 2 2 2 2
Enter the order of Matrix B : 2 3
Enter the Elements of B :
3 2 1 4 5 3
Matrix A is :
2 2 2
2 2 2
Matrix B is :
3 2 1
4 5 3
Multiplication is not possible
/*Matrix Addition*/
# include <stdio.h>
# include <conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10];
int i,j,r1,c1,r2,c2;
clrscr();
printf("\n\t\t***Matrix Addition***\n\n");
printf("Enter the order of Matrix A : ");
scanf("%d %d",&r1,&c1);
printf("\nEnter the Elements of A :\n");
for (i=0;i<r1;i++)
for (j=0;j<c1;j++)
scanf("%d",&a[i][j]);
printf("\n\nEnter the order of Matrix B : ");
scanf("%d %d",&r2,&c2);
printf("\nEnter the Elements of B :\n");
for (i=0;i<r2;i++)
for (j=0;j<c2;j++)
scanf("%d",&b[i][j]);
clrscr();
printf("\n\nMatrix A is :\n");
for (i=0;i<r1;i++)
{
for (j=0;j<c1;j++)
printf("%2d ",a[i][j]);
printf("\n");
}
printf("\nMatrix B is :\n");
for (i=0;i<r2;i++)
{
for (j=0;j<c2;j++)
printf("%2d ",b[i][j]);
printf("\n");
}
if ((r1==r2) && (c1==c2))
{
for (i=0;i<r1;i++)
for (j=0;j<c1;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nAddition of A and B is :\n");
for (i=0;i<r1;i++)
{
for (j=0;j<c1;j++)
printf("%2d ",c[i][j]);
printf("\n");
}
}
else
printf("\nAddition is not possible");
getch();
}
Output:
***Matrix Addition***
Enter the order of Matrix A : 3 2
Enter the Elements of A :
1
3
2
4
3
2
Enter the order of Matrix B : 3 2
Enter the Elements of B :
2
1
1
2
3
4
Matrix A is :
1 3
2 4
3 2
Matrix B is :
2 1
1 2
3 4
Addition of A and B is :
3 4
3 6
6 6
***Matrix Addition***
Enter the order of Matrix A : 2 2
Enter the Elements of A :
1
1
1
1
if (s[i].avg>=75)
s[i].grade='A';
else
If ((s[i].avg>=60)&&(s[i].avg<75))
s[i].grade='B';
else
if ((s[i].avg>=50)&&(s[i].avg<60))
s[i].grade='C';
else
s[i].grade='F';
}
printf("\n\nRollNo\tName\tM1\tM2\tM3\tTotal\tAverage\tGrade\n");
printf("_____________________________________________________________\n
")
for (i=0;i<n;i++)
{
printf("\n%d\t",s[i].Rollno);
printf("%s",s[i].name);
printf("\t%d\t%d\t%d",s[i].m1,s[i].m2,s[i].m3);
printf("\t%d\t%5.2f\t%c",s[i].total,s[i].avg,s[i].grade);
}
getch();
}
Output:
***Students Mark Calculation***
Enter the no. of students : 3
Enter the details of student 1
RollNo : 1009
Name : ABC
M1, M2, M3 : 78 90 67
Enter the details of student 2
RollNo : 1142
Name : DEF
M1, M2, M3 : 67 59 87
Enter the details of student 3
RollNo : 1256
Name : GHI
M1, M2, M3 : 37 40 45
RollNo
Name
M1
M2
M3
Total
Average
Grade
____________________________________________________
1009
ABC
78
90
67
235
78.33
1142
DEF
67
59
87
213
71.00
1256
GHI
37
40
45
122
40.67
Output:
***Employee Payslip Preparation***
Enter the no. of employees : 3
Enter the details of employee 1
Employee Id : 255
Employee Name : ABC
Basic : 5000
Enter the details of employee 2
Employee Id : 377
Employee Name : DEF
Basic : 7355
Enter the details of employee 3
Employee Id : 750
Employee Name : GHI
Basic : 8850
Empid Name Basic HRA
DA
EPF
Grosspay
Netpay
--------------------------------------------------------------------------------------------255
377
750
ABC
DEF
GHI
7400.00
10885.40
13098.00
break;
case 3: d=mul(a,b);
printf("\nProd is : %d",d);
break;
case 4: d=div(a,b);
printf("\nDiv is : %d",d);
break;
case 5: exit(0);
}
}
}
int add(int x,int y)
{
return (x+y);
}
int sub(int x,int y)
{
return (x-y);
}
int mul(int x,int y)
{
return (x*y);
}
int div(int x,int y)
{
return (x/y);
}
Output:
****Menu Driven Calculator
Enter the values of a and b : 18
**Main Menu**
1. Add
2. Sub
3. Mul
4. Div
5. Exit
Enter your option : 1
Sum is : 24
**Main Menu**
1. Add
2. Sub
3. Mul
4. Div
5. Exit
Enter your option : 2
Diff is : 12
**Main Menu**
1. Add
2. Sub
3. Mul
4. Div
5. Exit
Enter your option : 3
Prod is : 108
**Main Menu**
1. Add
2. Sub
3. Mul
4. Div
5. Exit
Enter your option : 4
Div is : 3
**Main Menu**
1. Add
2. Sub
3. Mul
4. Div
5. Exit
Enter your option : 5
Output:
***Fibonacci Series****
Enter the no. of Terms : 8
Fibonacci Series is :
0
13