# Coding Sample Questions | Part 5 | Codewindow.in

## Solution :

### C

// https://codewindow.in

#include "stdio.h"
#include "math.h"
int main()
{
double p,s,mi,sum,emi,bank[5],sq;
int y,n,k,i,yrs,l=0;
scanf(" %lf",&amp;p);
scanf(" %d",&amp;y);
for(k=0;k&lt;2;k++)
{
scanf(&quot; %d&quot;,&amp;n);
sum=0;
for(i=0;i&lt;n;i++)
{
scanf(&quot; %d&quot;,&amp;yrs);
scanf(&quot; %lf&quot;,&amp;s);
mi=0;
sq=pow((1+s),yrs*12);
emi= (p*(s))/(1-1/sq);
sum= sum + emi;
}bank[l++]=sum;
}
if(bank[0]&lt;bank[1])
printf(&quot; Bank A &quot;);
else
printf(&quot; Bank B &quot;);
return 0;
}

// Telegram @codewindow

### JAVA

// https://codewindow.in

import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double p,s,mi,sum,emi,sq;
int y,n,k,yrs,l=0;
double[] bank = new double[5];
System.out.println("Enter the principal amount");
p = sc.nextDouble();
System.out.println("Enter tenature year");
y = sc.nextInt();
for (k = 0; k &lt; 2; k++) {
System.out.println(&quot;Enter the no of slabs&quot;);
n = sc.nextInt();
sum=0;
for (int i = 0; i &lt; n; i++) {
System.out.println(&quot;Enter the period :&quot;);
yrs = sc.nextInt();
System.out.println(&quot;Enter the interest :&quot;);
s = sc.nextDouble();
mi=0;
sq=Math.pow((1+s), yrs*12);
emi=(p*(s))/(1-1/sq);
sum=sum+emi;
}
bank[l++]=sum;
}
if(bank[0]&lt;bank[1])
System.out.println(&quot;Bank A&quot;);
else
System.out.println(&quot;Bank B&quot;);
}
}

// Telegram @codewindow

### Python

# https://codewindow.in

bank = []
principal = int(input())
year = int(input())
for i in range(0, 2): # 2 Banks
installments = int(input())
sum = 0
for i in range(0, installments):
time, roi = [float(i) for i in input().split()]
square = pow((1+roi), time*12)
emi = (principal*(roi)/(1-1/square))
sum = sum + emi
bank.append(sum)
if bank[0] &lt; bank[1]:
print(&quot;Bank A&quot;)
else:
print(&quot;Bank B&quot;)

# Telegram @codewindow