+ 2

Question!

Hi! My first post. Someone can explain me this? if (y>ages[x]) { y=ages[x]; } 🙂 https://code.sololearn.com/cWBKCc6ZqgZw/?ref=app

16th Apr 2022, 7:27 PM
Dana
6 Answers
+ 3
if y value is greater than ages[x] then set y to ages[x]; smaller value.. May be snippet from : Find smallest among ages in array ages[]
16th Apr 2022, 7:33 PM
Jayakrishna 🇼🇳
+ 2
Jayakrishna🇼🇳 I think I finally understood! Thank you!
16th Apr 2022, 7:46 PM
Dana
+ 1
First line: int ages[5]; Creats 5 memory locations for ages {[ages[0]],[ages[1]],[ages[2]],[ages[3]],[ages[4]]} Your code then sets each location to what the user enters: for (int i=0; i < 5; ++i) { cin>>ages[i]; } Request memory locations of type float for edades & act float edades; float act; edadaes value is set to the same thing [ages[0]] is edades = ages[0]; Using a for loop it looks at [ages[x]] and compares it to adades so instead of x it will be ages[0], ages[1].. etc. for (int x=1; x < 5; ++x) { if (edades > ages[x]) { edades = ages[x]; }
16th Apr 2022, 7:39 PM
William Owens
William Owens - avatar
+ 1
William Owens Thank you!
16th Apr 2022, 7:49 PM
Dana
+ 1
That can be write in more readable way simply is like : if( ages[x] < min) min = ages[x]; //take less value among two Dana You're welcome
16th Apr 2022, 7:53 PM
Jayakrishna 🇼🇳
0
Description:You are required to write a serial program that performs multiplication for two n-digits decimal integers using the basic simple algorithm you learned in primary school.This is solo homework –no teams.Tasks:1.You will be given the file serial.c, put all of your code there. Do not create any additional files. 2.Use the below examples to test the correctness of your code. just use loop and method.
1st May 2022, 11:23 PM
Mukarram AL Matiany
Mukarram AL Matiany - avatar