Could you please tell me what is wrong with my code because the results i take after i compile it are wrong
ps.This is my first programm in C
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
float V, Imax, Imin;
int n, i;
printf("Dwste ton arithmo twn antistasewn\n");
scanf("%d", &n);
printf("Dwste thn timh ths tashs V\n");
scanf("%f", &V);
printf("Dwste thn megisth timh ths entashs tou reumatos\n");
scanf("%f", &Imax);
printf("Dwste thn elaxisth timh ths entashs tou reumatos\n");
scanf("%f", &Imin);
float Rmax=0., Rmin, Srow=0., Spar=0., R;
int counter=0;
for (i=0; i<n; i++ ) {
printf("Dwste thn timh thw antistashs se om\n");
scanf("%f", &R);
if (R>0) {
if ( (Imin<=V/R) && (V/R<=Imax) ) {
Srow=Srow+R;
Spar=Spar+1./R;
counter=counter+1;
if (i==0){
Rmin=R; }
else {
if (R>Rmax){
Rmax=R;} // end if
if (R<Rmin) {
Rmin=R; } // end if
} // end if
}
else {
printf("H entash tou reumatos pou diaperna auth thn antistash den anhkei sta epitrepta oria\n"); } // end if
} // end if
else{
printf("H timh thw antistashs prepei na einai megaluterh tou mhdenos\n"); } // end if
} // end for
Spar=1./Spar;
printf("%d Oi antistaseis pou eginan dektes htan sunolika\t", counter);
printf("%f H timh ths megaluterhs antistashs htan\t", Rmax, "\n" );
printf("%f H timh ths mikroterhs antistashs htan\t", Rmin, "\n" );
printf("%f An oi antistaseis sundeontan se seira tote h sunolikh antistash tha htan\t" ,Srow, "OM\n");
printf("%f An oi antistaseis sundeontan parallhla tote h sunolikh antistash tha htan\t" ,Spar, "OM\n");
}