Skip to main content

Featured

Data of Employees using Structure

There is a structure called employee that holds information like employee code, name, date of joining. That is a program that creates an array of the structure and enters some data. Then ask the user to enter current date. After that Display the names of those employees whose tenure is 3 or more than 3 years according to the given current date. #include<stdio.h> #include<stdlib.h> struct emp{     int code,date;     char name[16]; }; int main() {      struct emp e[20];      int x,i,j,cdate,res;      printf("How many employee are there?");      scanf("%d",&x);      for(i=0;i<x;i++)      {          printf("Enter Employee code:");//int          scanf("%d",&e[i].code);          printf("Enter employee name:");          scanf("%s",e[i].name);       ...

Permutation and Combination using C

[ Here I have made a program that calculates permutation and combination of selected input ]

Code:]

#include <stdio.h>
#include <stdlib.h>
int main()
{   int n,r,c,p;
    printf("Enter the value of n and r in nCr and nPr : ");
    scanf("%d",&n);
    scanf("%d",&r);
    int factr=1;
    int factn=1;
    int factnr=1;
    int i;
    for(i=1;i<=n;i++)
    {
        factn=factn*i;
    }
    for(i=1;i<=r;i++)
    {
        factr=factr*i;
    }
    for(i=1;i<=(n-r);i++)
    {
        factnr=factnr*i;
    }
    c = factn/(factr*factnr);
    p = factn/factnr;
    printf("%dC%d = %d , %dP%d = %d ",n,r,c,n,r,p);
return 0;
}

Popular Posts