Result of this Program in C

–1 vote
asked Mar 29, 2019 by Vamsi
int main()
{
    int i;

for (i=0;i<=10;++i)
        display(--i);  

return 0;
}
void display(int );
void display(int m) {
    printf("%d",m);
    }

2 Answers

0 votes
answered Mar 30, 2019 by anonymous
it will give compiler error

you should write function definition before main program so it can identify there is such a function in program
0 votes
answered Oct 15, 2019 by saiteja (270 points)

The answer for the program entered is -1,-1,-1.......upto infinite. Because the initial value of 'i' taken in for loop is 0 and you are displaying --i.

So, the answer will be -1,nothing will print for m.

#include<stdio.h>
void display(int m);
int main()
{
    int i;
    for(i=0;i<10;++i)
    {
        display(--i);
    }

    return 0;
}    
    
    void display(int m)
    { 
        printf("%d",m);
        
    }
    

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...