A computer science problem by edil tizon

What happens with the following program?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include<stdio.h>
int main(){
    struct emp{
        char name[25];
        int age;
        float sal;
    };
    struct emp e[2];
    int i=0;
    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal);

    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, e[i].age, e[i].sal);
    return 0;
}

Error: Floating point formats not linked Abnormal program termination. The code runs successfully. Error: scanf() function cannot be used for structures elements. Error: structure variable must be initialized.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Bhavesh Ahuja
Feb 6, 2015

Obviously floating points are not linked. There will be an error because after the second for loop it should be & e[i].sal and not e[i].sal for floating points to be linked!

in response to Bhavesh Ahuja.yeah so that is the correct answer good that you know.

edil tizon - 6 years, 4 months ago

Log in to reply

sorry my question, but what software is used for problems on computer science? (I'm starting and only know python)

Hjalmar Orellana Soto - 5 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...