Does this code make sense now as far as the logic goes?
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=0;
float success=0,i=0;
srand(time(NULL));
float total_success=0;
//prompts and scans
printf("\nHow many times? ");
scanf("%d", &request);
//calculation
for(i;i<request;i++)
{
if (((rand()%100+1)<=79)||((rand()%100+1)<=74))//component A or B
{
if (((rand()%100+1)<=89) )//component D
success=1; //if it makes it through A or B and then through D, it's successful
else
success=0;
}
if (((rand()%100+1)<=89))//component C
{
if (((rand()%100+1)<=69))//component E
success=1;//if it makes it through C and E, it will be successful
else
success=0;
}
total_success += success;
}
printf("\ntotal successes: %f", total_success);
printf("\ntimes: %f", i);
rblty=total_success/i;
printf("\nReliability: %f%% \n", rblty *100);
return 0;
}