Wil anyne plz spare ur time and solve this code??Its showing error.. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Wil anyne plz spare ur time and solve this code??Its showing error..

https://code.sololearn.com/cm9PRP6kzhX2/?ref=app

9th May 2020, 1:00 PM
Amirtha K
Amirtha K - avatar
3 Respostas
+ 4
for(int i=0;i<n;i++) { scanf("%d",&arr[i]); for(int i=0;i<=(i/2);i++) //here again reinitializing i again, will result may confusion or undefend behaviour.. Am i<i/2 never true, { for(int j=n;j<=(i/2)+1;j--) this also, { Edit: Amirtha K By first loop, take all inputs so, close brace} there, not include it to next loops,.. And you don't need 2 loop next, 1 is enough, otherwise you compare double times, intilize i, j in 1loop, simultaneously do i++, j--. And condition for j is j>=(n/2), not <=. Try these changes now...
9th May 2020, 1:15 PM
Jayakrishna šŸ‡®šŸ‡³
+ 1
Good one, just for information I'm adding this code, which is reduced more, take a look.. #include <stdio.h> int main() { int n,arr[30],c,b,d; scanf("%d",&n); for(int i=0;i<n;i++) //remove = scanf("%d",&arr[i]); //here any 1 condition is enough but adding 2 for(int i=0,j=n-1;i<(n/2) && j>=(n/2);i++,j--) { //not need if.. c=arr[i]+arr[j]; b=c/10; d=c%10; printf ("%d ",b); printf ("%d\n",d); } return 0; } And You're welcome...
9th May 2020, 2:09 PM
Jayakrishna šŸ‡®šŸ‡³
- 1
Haiyooo...U hlped me a lottt...But all i can say is a virtual thanks from the bottom of my heart..Really thanx a lott..I'm getting itšŸ˜šŸ˜šŸ˜šŸ˜šŸ˜‡šŸ˜‡šŸ˜‡Eeeeeeeeeeeee
9th May 2020, 1:57 PM
Amirtha K
Amirtha K - avatar