what should i do?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CLYXZ
    New Member
    • Feb 2014
    • 1

    what should i do?

    Code:
    #include<stdio.h>
     #include<conio.h>
     int i;
     main()
     {
     clrscr();
     for (i=1;i<10;++)
     { printf("%d",i*5);
     } 
    getch(); 
    }
    the output should be -5 10 -15 20 -25 30 -35 40 -45 50
    Last edited by Rabbit; Feb 16 '14, 04:35 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • stdq
    New Member
    • Apr 2013
    • 94

    #2
    Hello! In the header of the for statement, shouldn't it be ++i in the third portion? Also, "-" in the output means a negative sign? If so, your logic seems to be incorrect. Because, you need to check if the number is odd - if it is, you should print - i * 5 and not i * 5. Otherwise, the printf call is enough. Also, the condition for continuing the loop should be i <= 10, so that 50 is also included in the output.

    Comment

    Working...