+ 1
Hey can anyone tell me why i++ is not working on line no. 20
I+1 is working but I++ is not. What's the difference between them here. https://code.sololearn.com/cnPLtoAFlRus/?ref=app
3 Answers
+ 8
i++ adds 1 and stores it in i, while i+1 just output value i by 1 more.
In general, "i" is not needed here āŗļø:
int largestElement(int a[],int size){
static int larg;
if(a[size]>larg)
larg=a[size];
if(size>1)
largestElement(a,size-1);
return larg;
}
And don't forget about #include <stdio.h>
+ 6
If you use ++i (pre-increment operator) it works. If you use i++ (post-increment operator), value of <i> is not modified until the current line is completely processed.
It's also great to understand the use case, where to use increment or decrement operator with a variable, and when to just add a value to a variable.
+ 5
raisun lakra
Do ++i
because i++ is post increment so 0, 0, 1, 2, 3
and on ++i , 0, 1, 2, 3