what is the output of following question?
void main()
{
int i=0,a[3];
a[i]=i++;
printf("%d",a[i]
}
Answer Posted / ankur mohan sharma
A garbage value
Explanaiton:-since we have post increment operator applied on i. It's value gets incremented in next statement, so
a[i]=i++ means a[0]= 0
so a[0] is assigned value 0;
and now i becomes 1;
In next statement value of a[i] is to be printed which means value of a[1], which is not initialised. So value printed is a
garbage value.
Remarks
1. An uninitialised variable holds a garbage value.
2. Post increment operator increments value in next line.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between class and object in c?
What are linked lists in c?
What is the size of structure in c?
Write a program to print fibonacci series using recursion?
Is a house a shell structure?
What are pointers? Why are they used?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
What is table lookup in c?
explain what is an endless loop?
Is struct oop?
What do you mean by dynamic memory allocation in c? What functions are used?
Explain about block scope in c?
What is calloc()?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.