error

what is the error in the following code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  #include <stdio.h>
int main()
{
    int rows,i,c;
    scanf("%d",&rows);
    for(i=0;i<rows;i++)
    {
        for(c=1;c<=(2i+1);c++)
           {
             printf("*");
           }
        printf("\n");
    }
}
i think you got a typo error.

fix code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 #include <stdio.h>
int main()
{
    int rows,i,c;
    scanf("%d",&rows);
    for(i=0;i<rows;i++)
    {
        for(c=1;c<=(i+1);c++)
           {
             printf("*");
           }
        printf("\n");
    }
}
what is the error in the following code?

The compiler should say something. If it does, then it should tell the line, where it sees an error.

It is very useful to learn to check the feedback of the compiler and to learn to interpret the error messages.

It is also good Forum practice to post those error messages. It helps others to help you.
C:\Users\Mehak\Desktop\prac\8.c||In function 'main':|
C:\Users\Mehak\Desktop\prac\8.c|9|error: invalid operands to binary <= (have 'int' and 'complex int')|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|
not even trying to understand the errors?

not even trying to understand the errors?
I would have to agree the error is pretty specific :
In function 'main':| ... |9|error: invalid operands to binary <= (have 'int' and 'complex int')|

2i != 2 * i if that is what you are trying to do.

If you are trying to use a complex number then I'd like to know what exactly you are trying to do. It'd be hard to loop an imaginary amount of times.
The error is in file that has name "8.c".
The error is probably on line 9 of that file. (Your post on this thread has it on line 8.)
The line with error has binary operator <=.
One of the operands has type 'int' and the other has type 'complex int'.

One should be able to locate both operands from the code. Then one can figure out how the intent (by author) and the interpretation (by compiler) of the code differ.
Topic archived. No new replies allowed.