From 5f89a7763e54c6cfd6efa786dc23a89c6aacd93f Mon Sep 17 00:00:00 2001 From: Peter Sabol Date: Fri, 18 Mar 2022 12:45:58 +0100 Subject: [PATCH] funguje --- du3/program | Bin 5822 -> 5694 bytes du3/program.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/du3/program b/du3/program index 1b0be0797dd9f658321eebf44272aaa1d9ea88bc..14d0d4bd61760b6d26c55b8c67f5bd3001ff49e8 100755 GIT binary patch delta 1638 zcmYjRT}+#06h3eN_)37TEeH%<3lu1(gkoSrwna2G(96_VP;;K#h(QexmXskz_Kgx=Sscs2VLtRVOcOU!F@jGE7g6;*XNw)ocEmP zeZSN9dfj#3wA*kocc$XSN4yFVzh=U-he!Z)?xIQY&RiMZ~!q?_4A4cZ-YB%$~d#~p07|}S$h{{LR4JCC20>+Xr6%i%W9Zl257vtvCevs<2ay&^|QzNpqs%HFxB&~|8 zN7+pOjC8GvyF@v5B)z5++%Af(QF>ALxoxzB{m*ru+eh8(&%tlld|~nzb$zQn)DfL~ z0};RMFxBrrj-_U7Z6BNbUEL_TVe)WLTf3Q@o{Cq~0(*6x@=H_g zs2=#117B40s`H1Lp+Tp%kH9NRMDiI*uQX ztZ%6s?Kc9RHZBe!i%^|<|GuV81w4Vtz^KOr@((7HAYpH?eSz(OC&-I#S0J?{5%L6= zel>`-$-w_hrje#1O(an4aTu?Dj|x?ofmBnbMeBpd>ic1fSMApgSYp= zYn}Yc_E|^|1UX6X)~5ENgL)2XMt($6+iuCj+~(_lG!2LM;B)NR2JM-nx`46dwga=V z@o=KonR=qkc+iWw7CegZ!8zy2n_(mae~AC`Z^;-X$z zUQlWF!ScZ>mM07H%shvF`7(I@YLK&>fdTf(C0Kq~ewl{V4y#?-ZI$|XcOvSPL0h5d zlwGzO!?abtX{#1zE)-_G*nedqtJ75eU*Hck!}s|6)`(a62!iMvD`=&TYNLtcP`-+j~{kuR^bVaH{uSAijL??Ze)M zi}19|!={=YzaywRhEHHE;!r?E4=-Oh2y;6u<7{f{-j)>r3r_SQK~Fm7Vw_+w3jtg_q=8Gbe8f0J!j zlKulMpN1S{f46fCb?@&DCWTb|1&*mo)~E=6rN>PEVGz+L{rpPe00IIb-6;a&I#TD2 zjb$t6lDt#Z=jysE?oQ5u_uZMfEBcI{&iDVCN`^;Il?(})xYI|EtXKUL>%?&N-*rpA!jcsm^r@67&-Rdhp z$Mya<zYvv$@y%DnG@nt+h2+$wdTi zQAqBC6owR*&5)vyqH+Kd-?13Hb~&3{AY$@fZn+`fA}x7kVp-Pal^b3w7GnFil1ySs94QG8)Oopsxd?k#M#!m^h=63K)o~Ga3o+90pH-(MZoS zY$KjW(on=eJe#Cmtm{0dq|VDu6qAM48Z30Zb+1)_NnjJ$0zRi9dD-d^!}7YdreWw( zGEabL6uvYO0U~!eHbsO$`~mbdF#%$apz~e;Fzl3t!;$7CsF)nk7i7JyMnq+Y&9Pa3 z%6|RznF*!MZM2Z4PTY7Q6wuHp(T!U&kHkvOCIn h8~A8hQPU3V#tshXulAUfDj`3#zbIlOm+e0o{sjT~C#e7c diff --git a/du3/program.c b/du3/program.c index cd08524..97c7a45 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,15 +1,16 @@ #include #include #include +//#include -int main() +/*int main() { float a[100],sum=0,x; int n,i; printf("\nEnter the value of X :: "); scanf("%f",&x); - printf("\nEnter degree of the polynomial X :: "); - scanf("%d",&n); + // printf("\nEnter degree of the polynomial X :: "); + //scanf("%d",&n); printf("\nEnter coefficient's of the polynomial X :: \n"); for(i=n;i>=0;i--) { @@ -27,4 +28,34 @@ int main() printf("\nValue of the polynomial is = [ %f ]\n",sum); return 0; +} +*/ + +void main() { + int degree,x; + int coeff[10], i; + int sum = 0; + + // Getting the degreee of the polynomial + printf("\nEnter the degree of the polynomial: "); + scanf("%d",°ree); + + // Getting the coefficients of all terms of the polynomial + printf("\nEnter the coeffients from lower order to higher order: \n"); + for(i=0; i<=degree; i++) { + scanf("%d",&coeff[i]); + } + + // Getting the value of the variable + printf("\nEnter the value of x: "); + scanf("%d",&x); + + // Applying Horner's rule + sum = coeff[degree]; + for(i=degree-1; i>=0; i--) { + sum = sum*x + coeff[i]; + } + + // Printing result + printf("\nResult: %d",sum); } \ No newline at end of file