I have created structure and have given values for load, C and G. I want user to input load and it must match with one of the load from structure. Then the values of C and G for corresponding load should be taken for further calculation. My problem is that whenever I enter load for example 1 then it must take value of C as 38 but instead it take 2293652. Even if I enter other value of load still it takes same. I am from Mechanical background so don't go hard on me
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
using namespace std;
struct hook{
float SL;
int C;
int G;
};
struct hook h[]={
{0.5, 27, 14},
{1, 38, 20},
{2, 53, 27},
{3.2, 68, 35},
{5, 85, 42},
{8, 107, 55},
{10, 119, 60},
{12, 134, 68},
{16, 151, 76},
{20, 169, 80},
{25, 189, 90},
{32, 207, 100}
};
int main()
{
float SL1;
int C1, G1;
cout << "Enter the safe working load:\n" << endl;
cin >> SL1;
int i;
i >=0;
for (i=0; i < sizeof h /sizeof *h; i++){
if(h[i].SL == SL1){
h[i].C = C1;
h[i].G = G1;
break;
}
}
float H=0.93*C1, M=0.6*C1, Z=0.12*C1;
cout << C1 << endl;
return 0;
}