Reliability With Random numbers.
Write a program to test the circuit reliability with random numbers as many times as the user requests.:confused:
The circuit: I can't figure out how to get the attachment to work so here's my best at describing the circuit in words. A(reliability .80) is parallel with B(r=.75). AB is in series with D(r=.90). C(r=.90) is in series with E(r=.70). CE is in parallel with ABD.
I have this so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//prototypes (function announcement)
//function main
int main ()
{
// declarations and initialzations
float rblty=0;
int request;
float success=0,i=0;
srand(time(NULL));
//prompts and scans
printf("\nHow many times? ");
scanf("%d", &request);
//calculation
for(i;i<=request;i++);
{
if ((rand()%101)<=69)//component E
{success+=1;}
if ((rand()%101)<74) //component B
{success+=1;}
if ((rand()%101)<=79)//component A
{success+=1;}
if ((rand()%101)<=89)//component D
{success+=1;}
if ((rand()%101)<=89)//component C
{success+=1;}
rblty= (success)/i;
}
printf("Reliability: %f%% ", rblty *100);
return 0;
}
I think the random numbers are working, but I can't figure out how to connect the reliability for the components to one another to find the total number of successes and I'm calculating the total reliability based on reliability=number of successes/number of trials. Any help would be greatly appreciated.