Skip to main content

Featured

C Program to display spellings of number 1-10 on entry

C Program to display spellings of number 1-10 on entry.   #include<stdio.h>   void main() { int num; printf("Enter a number between 1-10:"); scanf("%d",&num); printf("\n"); switch (num) { case 1: printf("ONE"); break; case 2: printf("TWO"); break; case 3: printf("THREE"); break; case 4: printf("FOUR"); break; case 5: printf("FIVE"); break; case 6: printf("SIX"); break; case 7: printf("SEVEN"); break; case 8: printf("EIGHT"); break; case 9: printf("NINE"); break; case 10: printf("TEN"); break; default:         printf("THE ENTERED NUMBER IS NOT BETWEEN 1-10"); } } OUTPUTS

C Program to calculate the value of nCr , n≥r using function

C Program to calculate the value of nCr,n≥r using function

#include<stdio.h>
int fact(int);
void main()
{
int n,r,c;
 printf("Enter the value of n & r (n>=r) for nCr: ");
scanf("%d,%d",&n,&r);
if(n>=r)
{
c=fact(n)/(fact(r)*fact(n-r));                    
                 //The formula is: nCr=n!/(r!*(n-r)!)
  printf("\n\nThe value of %dC%d is: %d",n,r,c);
 }
else
printf("\n n is less than r");
}
int fact(int val)
{
int f=1;
while(val>0)
{
f*=val;
val--;
 }
return(f);
}


OUTPUT




Comments