C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Point Out Errors (Q.No. 5)
5.
Point out the error in the program?
#include<stdio.h>
int main()
{
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i;
for(i=0; i<=9; i++)
scanf("%s %f", e[i].name, &e[i].sal);
return 0;
}
Answer: Option
Explanation:
At run time it will show an error then program will be terminated.
Sample output: Turbo C (Windows)
c:\>myprogram
Sample
12.123
scanf : floating point formats not linked
Abnormal program termination
Discussion:
28 comments Page 2 of 3.
Novice_user said:
2 decades ago
When run with gcc it shows no error and the program runs fine.
Why there is linking problem in Turbo C??
Why there is linking problem in Turbo C??
Shivani said:
1 decade ago
Its necessary to use address operator while taking the input by using scanf() except with %s.
Nagaraj said:
1 decade ago
Ya, it doesn't support float, we have to cast inoder to change it to float.
Nidhinpradeep said:
1 decade ago
Here no comma seperating %s ND % f.
So floating format is not linked.
So floating format is not linked.
Rohit said:
1 decade ago
The pgm will work 100% correctly. There is no prob of linker.
Rrk said:
1 decade ago
I agree with you Sanjeev. But in the question scanf is used.
Ankit ardeshana said:
1 decade ago
I have run this program with GCC. It executed successfully.
Anusha said:
1 decade ago
Kindly wish to all. Please tell me why it is linked error?
Preethi said:
2 decades ago
What does it mean "floating point formats not linked" ?
Trupti said:
1 decade ago
Program is right. No error and no output.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers