0

Product of odd numbers from 1 to 15...its where am stuck my outputs are 1 3 5 7 9 11 13

int x=1 while(x<15) { Console.WriteLine(x); x+=2;

19th Jul 2018, 6:50 AM
Abby
Abby - avatar
7 Antworten
+ 1
If you want the product: int x = 1; int temp = 1; while(x<16) { temp = temp * x ; x += 2; } console.writeln(temp);
19th Jul 2018, 7:49 AM
Nehal
Nehal - avatar
+ 1
I actually wanted him/her to figure it out on his/her own, the learn effect is greater in such a case. But ok
19th Jul 2018, 8:18 AM
Matthias
Matthias - avatar
0
want single number
19th Jul 2018, 6:51 AM
Abby
Abby - avatar
0
x<=15 if 15 should be included use another additional variable, were you compute the product prod = prod*x
19th Jul 2018, 6:54 AM
Matthias
Matthias - avatar
0
where do i insert the prod
19th Jul 2018, 7:11 AM
Abby
Abby - avatar
0
Abigael Irene Nyangasi Before the loop after 'x' declaration. You have to set it to 1 int prod= 1; so you can repeat multiplication in loop
19th Jul 2018, 7:35 AM
KrOW
KrOW - avatar
0
Am a begginer in this
19th Jul 2018, 8:41 AM
Abby
Abby - avatar