C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Point Out Errors (Q.No. 3)
3.
Point out the error in the following program.
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
emp int xx;
int a;
printf("%d\n", &a);
return 0;
}
Answer: Option
Explanation:
There is an error in the line emp int xx;
To overcome this error, remove the int and add the struct at the begining of emp int xx;
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
struct emp xx;
int a;
printf("%d\n", &a);
return 0;
}
Discussion:
30 comments Page 3 of 3.
Vasantha deepika said:
1 decade ago
& operator should not be used in printf() statement .
Hashni said:
1 decade ago
& Operator should be used only in scanf() statement.
Revathy said:
1 decade ago
struct emp xx;
What does tis statement do?
What does tis statement do?
Divya said:
7 years ago
where is "int a" used? Please explain me.
Dan said:
1 decade ago
We can't write & in printf statement.
Kalyani said:
7 years ago
Could anyone please explain what is emp?
(1)
Subhra said:
8 years ago
The printf will print the address of a.
(1)
Sameera said:
1 decade ago
You are correct vasantha deepika.
Swetha said:
1 decade ago
Can any one explain in detail?
Sri said:
9 years ago
Why should we place struct?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers