int i =10
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10
i++;
}
printf("%d", i);
Answer Posted / guest
the print would be 20.
the problem is about scope. the first i=10 is global scope.
But inside main() comes function scope. So i=20. The i
inside the for loop is of block scope and does not affect
the i outside it.
Is This Answer Correct ? | 5 Yes | 9 No |
Post New Answer View All Answers
Explain logical errors? Compare with syntax errors.
How do you declare a variable that will hold string values?
What does != Mean in c?
What is a MAC Address?
What is data types?
What is hungarian notation? Is it worthwhile?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
When should a type cast be used?
Which is better between malloc and calloc?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
Why dont c comments nest?
When should a far pointer be used?
Why c is called a mid level programming language?
provide an example of the Group by clause, when would you use this clause
What is the difference between char array and char pointer?