Issue with arrays. Program giving unexpected output

+1 Joel Lukombo · November 11, 2015

#include<stdio.h>
#include<conio.h>
main()
{
int dave[5]={8,6,5,7,9};
int a;
int total=0;
for(a=0;a<5;a++)
{
total+=dave[a];

}
printf("%d",total);
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Joel Lukombo · November 12, 2015
The output is :"your number is 3"
0 c student · November 13, 2015
works fine
http://ideone.com/iDiktd
+1 Jon Z. · November 13, 2015
Looks fine to me. If you have issues get rid of the conio library since you don't need it, and give a new line at the end when you print. 


//#include<conio.h>
printf("%d\n",total);
0 Joel Lukombo · November 15, 2015
Tried all of your suggestions but nothing seems to help. I guess it is just a bug. Thanks anyways !! :)
0 Jon Z. · November 15, 2015
post a screenshot of your code and output.
  • 1

C

107,205 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator