Question

what I entered in editor:

 i1 = input("1 :");
i2 = input("2 :");
i3 = input("3 :");
i4 = input("4 :");
i5 = input("5 :");

media = (i1 + i2 + i3 + i4 + i5)/2 ;

print(media);

what do I get :

1 :2
2 :3
3 :4
4 :5
5 :6
print(media);
             !--error 42 
Incompatible input argument.
at line       9 of exec file called by :    
exec('C:\Users\*****\Documents\scilab\media2.sce', -1)

I would like to know what is wrong

Était-ce utile?

La solution

Print

Print is mostly used to print variables to a file. It could be used to print to the display, but you should give %io(2) as file argument as mentioned in the documentation. So then, your code would become:

print(%io(2), media );

Disp

The usual syntax for displaying results within Scilab is disp.

disp(media);

or

disp("Media is: " + string(media) );

Printf

You could also use the more c-style printf function as such

printf('Result is:\n media=%f',media);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top