// Java program to calculate the// value of nCrimportjava.util.Scanner;publicclassMain{staticintgetFactorial(intnum){intf=1;inti=0;if(num==0)return1;for(i=1;i<=num;i++)f=f*i;returnf;}publicstaticvoidmain(String[
i = 2 and i <= n and i++ Set temp = temp * i End return temp step 2 -> declare function to calculate ncr int nCr(int n, int r) return cal_n(n) / (cal_n(r) * cal_n(n - r)) step 3 -> In main() declare variable as int n = 12, r = 4 print nCr(n, r) ...
This question was asked during an interview with NCR. The factorial for a number ‘n’ would be n*(n-1)*(n-2)…*1. Problems like this that have a repetitive pattern tend to be more easily solved by using recursion. Taking a closer look at the problem, we could also say that the...
Here, we are going to learn about the Cosine(X), and learn how to calculate the Cosine(X) using a predefined method in C#?ByNidhiLast updated : April 15, 2023 Here, we calculate theCosine(X)usingCos()method of Math class. C# program to calculate the Cosine(X) using a predefined met...
// Java program to calculate the// area of Cubeimportjava.util.Scanner;publicclassMain{staticfloatcalcuateAreaOfCube(floatside){floatresult=0.0F;result=6.0F*side*side;returnresult;}publicstaticvoidmain(String[]args){Scanner SC=newScanner(System.in);floatside=0;floatarea=0;System.out.printf("En...
C - Calculate value of nCr C - Calculate value of nPr C - Calculate product of two binary numbers C - Calculate addition of two complex numbers C - Extract last two digits from a given year C - Perform ATM Transactions C - Read height of a person andprint person is taller, dwarf, ...
area = (float)(4 * Math.PI * radius * radius); In theMain()method, we created two local variablesareaandradiusinitialized with 0. Then we read the value of the radius from the user, after that passed the value of radius intoCalculateArea()method that will return the calculated area th...
Compound Interest Compound interest is the addition of interest to the principal sum of a loan or deposit, or in other words, interest on principal plus interest. [Source] Note: Compound interest is the interest on a loan, which is calculated based on both the initial principal and the accum...
Calculate profit or loss in C language #include<stdio.h>intmain(){/*declare the variables*/intcp;intsp;intamount;/*enter the cost price*/printf("Enter the cost price:");scanf("%d",&cp);/*enter the selling price*/printf("Enter the selling price:");scanf("%d",&sp);/*if condition...
The source code to calculate the surface area, volume of the Cone is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully. // C program to find the surface Area and// volume of Cone#include <stdio.h>#include <math.h>intmain() ...