Hello. I am having an issue with my code that I cannot figure out. I have entered an equation and depending on what the result of the equation is, depends on the line of text the program will print on the screen. I will attach a copy of my code with the hopes it is a simple fix and I am just missing something obvious. No matter what the results of my equation is, the program will only print "In the elastic region" I appreciate any advice, thank you.
#include <stdio.h>
#include <math.h>
#define youngs_modulus 28000
#define elastic_limit 0.001527
#define yield_stress 30
#define k 184.923
#define n 0.45
/* Main function */
int main(void)
{
/* Declare variables */
double elastic_region, yielding, strain_hardening, necking, strain, stress;
/* Print headings */
printf("********************************************");
printf("\n STRESS AND STRAIN FOR 304 STAINLESS STEEL");
if(0.001527>=stress || stress>0)
well, by this statement ^^^ stress has to be negative or it is elastic.
conditions cost time and cpu effort.
reverse them to condense is easier to read and code:
if stress > 0.5
else
if stress > .002 //here, it can't be > 0.5 so its between .002 and .5
else
if stress > .001527 //here it cant be > .002, so its between again...