Where was I wrong?



  • Why do I keep showing zero?

        #include <stdio.h>
    #include <conio.h>
    #include <math.h>
    #include <stdlib.h>
    

    int main(void)
    {
    float f, n;
    int r = 0;
    int t = 2;

    printf("Vvedite n=");
    scanf_s("%f", &amp;n);
    
    if (0 &lt;= t &amp;&amp; t &lt;= 2) {
        f = 1.5 + r;
    }
    if (2 &lt; t &amp;&amp; t &lt; 5) {
        f = r;
    }
    if (5 &lt;= t &amp;&amp; t &lt;= 10) {
        f = 2 * r;
    }
    if (n == 1.5) {
        r = 2.5;
    }
    if (n == 3.4) {
        r = 1.5;
    }
    if (n == 2.6) {
        r = 10.5;
    }
    printf("f raven %d", f);
    getchar();
    system("pause");
    return 0;
    

    }



  • #include <stdio.h>
    #include <conio.h>
    #include <math.h>
    #include <stdlib.h>
    
    int main(void)
    {
        float f, n;
        int r = 0;
        int t = 1;
    
        printf("Vvedite n=");
        scanf_s("%f", &n);
    
        if (0 <= t && t <= 2) {
            f = 1.5 + r;
        }
        if (2 < t && t < 5) {
            f = r;
        }
        if (5 <= t && t <= 10) {
            f = 2 * r;
        }
        if (n == 1.5) {
            r = 2.5;
        }
        if (n == 3.4) {
            r = 1.5;
        }
        if (n == 2.6) {
            r = 10.5;
        }
        printf("f raven %f", f);
        getchar();
        system("pause");
        return 0;
    }
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2