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:
27 comments Page 2 of 3.
Shivani said:
10 years 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:
10 years 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:
1 decade ago
What does it mean "floating point formats not linked" ?
Trupti said:
10 years ago
Program is right. No error and no output.
K.maheswari said:
1 decade ago
Why it dsn 't support floating points ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers