+ 3

#include <stdio.h> int main() { int a[5]={1,2,3,5,8}; int first,second =0; for(int i=0;i<=4;i++) { if (a[i]>first ) {

what is wrong in this code?

14th Jul 2018, 5:07 AM
IShiva SHreya
IShiva SHreya - avatar
5 Antworten
+ 5
Hello, IShiva SHreya ! Please attach your code here, Sololearn has this option. And then people can help you!
14th Jul 2018, 5:12 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
first is not initialised , and u r using it to compare with a[i] , it will pick any garbage value and compare it with a[i].
14th Jul 2018, 5:13 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 3
14th Jul 2018, 5:18 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 3
I more suggestion IShiva SHreya for the next time try to post the question above and your doubt in description section, and try to post codes in playground section and link them here. Happy coding ✌🏻
14th Jul 2018, 5:30 AM
Nikhil Dhama
Nikhil Dhama - avatar
0
thanks :)
14th Jul 2018, 5:21 AM
IShiva SHreya
IShiva SHreya - avatar