what is the output of following question?
void main()
{
int i=0,a[3];
a[i]=i++;
printf("%d",a[i]
}
Answers were Sorted based on User's Feedback
my opinion or wat i think is that ,
a[i]=i++; is given so...
here i++ is a post increment operation , so first it will assign the value to a[0]=0 , so a[0] will have 0 , and in next line a[i] is given in printf , so the value a[1] should get printed that will be garbage value.......
thank u
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / sha
Vignesh, you are right about the post incerement operation.
The a[i]=a[0] which will be assigned 0 but the printf will
print 0 as output because its printing the a[0] and not a
[1].
Is This Answer Correct ? | 0 Yes | 0 No |
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 |
What is class and object in c?
#include<stdio.h> int main(){ int a[]={1,2,3,5,1}; int *ptr=a+4; int y=ptr-a; printf("%d",y); }
a c code by using memory allocation for add ,multiply of sprase matrixes
What does *p++ do?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What are the properties of union in c?
What happens if a header file is included twice?
Explain how do you convert strings to numbers in c?
Explain bit masking in c?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
0 Answers Aspire, Infogain, TISL,
Write a programm such that if user enter 11.25 it roundup to 11 but if user enter 11.51 upto 11.99 it will round up to 12 i.e.;convert the floting point value into integer format as explain above..
Go through this linked list concept.While traversing through the singly linked list sometimes the following code snippet "while(head != NULL)" is used and other times "while(head->link != NULL)"is used(Here head is the pointer pointing to the first node,node has two parts data part and link part).What is the difference between head != NULL and Head->link != NULL and in which situation are they used?