Write a c program to generate C-chart of control limit in statistics

How to write Program in C to generate C-Chart in statistics.

write a program to compute the control limits of C-chart in statics

C program to generate C-chart

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


void direct();
void indirect();

long int S_num, num, i,  D_num;
long int dfct=0, d[50];
float cl, ucl, lcl, z ;

void main()
{
     int ch;
     clrscr();

     while(ch!=5)
     {
          printf("\nenter your choice ");
          printf("\npress 1 for direct central line is given ");
          printf("\npress 2 for finding central line ");
          printf("\npress 3 for exit ");
          printf("\n");
          scanf("%d",&ch);
          switch(ch)
          {
               case 1 :
                    direct();
                    break;

               case 2 :
                    indirect();
                    break;

               case 3 :
                    exit(0);
                    break;
               default :
                       printf("\nu enter wrong choice \n");
                       break;
          }
     }
getch();
}

void direct()
{
     printf("\n enter the value of central line = ");
     scanf("%f",&cl);

     z=sqrt(cl);
     ucl=cl+3*z;
     lcl=cl-3*z;
     if(lcl<0)
          lcl=0;
     printf("\nthe value of central line cl =  %.3f",cl);
     printf("\nthe value of upper control limit ucl =  %.3f",ucl);
     printf("\nthe value of lower control limit lcl =  %.3f\n",lcl);
}


void indirect()
{

     printf("\n enter the total no of samples inspected = ");
     scanf("%ld",&S_num);


     printf("\n enter the total no of defects in all samples inspected = ");
     scanf("%ld",&D_num);
     printf("\n enter the no of defects in samples one by one \n");
     for(i=0;i<D_num;i++)
     {
          scanf("%ld",&d[i]);
     }
     for(i=0;i<D_num;i++)
     {
          dfct=dfct+d[i];
     }
     cl=(float)dfct/S_num;

     z=sqrt(cl);
     ucl=cl+3*z;
     lcl=cl-3*z;
     if(lcl<0)
          lcl=0;
     printf("\nthe value of central line cl =  %.3f",cl);
     printf("\nthe value of upper control limit ucl =  %.3f",ucl);
     printf("\nthe value of lower control limit lcl =  %.3f\n",lcl);

}

 

Add a Comment

Your email address will not be published.

nineteen − nine =