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
When would you use a pointer to a function?
How can a program be made to print the name of a source file where an error occurs?
What is the difference between the expression “++a” and “a++”?
Is fortran still used today?
How can you invoke another program from within a C program?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
What is scope of variable in c?
How can a program be made to print the line number where an error occurs?
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
What is class and object in c?
What are formal parameters?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
What is the use of ?: Operator?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
Explain data types & how many data types supported by c?