top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

what is meaning of return value in C language?

+3 votes
523 views
#include <stdio.h>
int main()
{
    char vowels[5]={'a','e','i','o','u'};
    int x;

    printf("Vowel Letters");
    for(x=0;x<=5;x++)
    {
         printf("\n %C",vowels[x]);
    }
}

Output

Vowel Letters
a
e
i
o
u
♣
Process exited after 0.1132 seconds with return value 3

What is the meaning of return value 3

posted Sep 21, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You are trying to print 6 characters where as you are assigned only 5 to vowels[]. Since there is no array boundary check in C, it will print the garbage character in next byte. You can correct it by changing the for loop like:
for(x=0;x<5;x++)
or
for(x=0;x<=4;x++)

But how did you check the return value ?

answer Sep 23, 2015 by Shivananda Gavalkar S
...