programm testing-Microsoft Visual Studio File Edil View Projet Build Debug Tei T
ID: 3724548 • Letter: P
Question
programm testing-Microsoft Visual Studio File Edil View Projet Build Debug Tei Tools Test Andlyze WirkowHelp Quick Launch (Ctrl-Q) Sign in Debug x86 Local windows Debugger x testing project.cpp UESIION MID IERM.cpp ]AIO ] r Miscellaneous Files … Eilire Solulion 1 Error 4 Wamings D Messages (Global Scope) Search Error List Code Description ype words to search for File Lire Suppression at programm testing testing project.cpp 31 //get the "urber of inputs that use'·intends tu provide frw, the user. 21 sling "%.'requires an argument of type 'int * hut variadic argument 1 has lype 'tkuble '. '': conversion from 'double' to int', possible loss of data double getinputs(dcuble* plnputs, int number0f1nputs) 23 24 int i; 27 printf( pleasc enter [Ed] inputs in, nunberofInputs):Masks user to enter n no of inputs A244 programm testing testing project.cpp 4/ 29 H - 1cnunberofFIrputs; 1++) can", &Irput;:[]):stones entcred inputs in an annay A C177 'print: format programm testing testing project.cpp 63 string "%d" requires an argument of type 'int, but variadic argumont 1 has type 'double 'pritf : not enough programm testing arguments passed for format string 38 int i .44/3 testing project.cpp 63 #1 double rcan; A/16 'getinputs": must return a value testing project.cpp 35 programm testing for (J-8; jenur berol Inputs 44) { sum sun + nputs [j];//calculating tatal sum of array -lenerits nean sum nunberOf Inputsmean is sus f array elenents divided y no of inputs 70%Explanation / Answer
The error is because the function getInputs is of type "double" i.e it has to return a value of type "double". But , you are not returning anything from the function. Hence, to avoid the error you can do two things:
1. You can return a value of type "double"
2. You can make the function as void . which means that the function returns nothing. Instead of "double getInputs(... )" , make it "void getInputs( ... )"
Other Suggestions:
In line 31 , in the scanf you have used the format specifier as "%d". But our array is of type double. Hence, it should be "%lf" . Corrected statement would be scanf("%lf",&pInputs[i]);
In the function getMean, the array is of type "double" and the variable 'sum' is of type "int". These two cannot be added. Corrected statement would be double sum = 0;
PLEASE UPVOTE IF THE ANSWER WAS HELPFUL
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.