Social Icons

Pages

C programe to find simple and compound interest

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

void main()
{
    float p,q,r,SI,CI;
    int n;
    clrscr();
   
    printf("Enter the value of Principal p = ");
    scanf("%f \n",&p);
    printf("Enter the value of Rate r = ");
    scanf("%f \n",&r);
    printf("Enter the value of Period n = ");
    scanf("%d \n",&n);
   
    SI = (p*r*n)/100;

    printf("Simple Interest SI=%f \n",SI);
   
    q = 1+(r/100);
    CI=p*pow(q,n);
   
    printf("Compound Interest CI=%f \n",CI);
   
    getch();
}

Hill Cipher Algorithm Program in C

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,ans[25][1],sum=0,mtrx[25][25],end;
char txt[25];
clrscr();
printf("\nEnter the string : ");
scanf("%s",txt);
//clrscr();
for(i=0;i<25;i++)
{
if(txt[i]>=97 && txt[i]<122) {}
else
{
end=i;
break;
}
}
for(i=0;i<end;i++)
{
//printf("initial : %d ",txt[i]);
txt[i]=txt[i]-'a';
//printf("final : %d ",txt[i]);
//printf("\n\n");
}
clrscr();
printf("\nEnter matrix...\n");
for(i=0;i<end;i++)
{
for(j=0;j<end;j++)
{
scanf("%d",&mtrx[i][j]);
}
}
for(i=0;i<end;i++)
{
sum=0;
for(j=0;j<end;j++)
{
sum+=mtrx[i][j]*(int)txt[j];
}
ans[i][0]=sum;
}
for(i=0;i<end;i++)
{
printf(" %c",((ans[i][0])%26)+97);
}
getch();
}