xxxolayxxx
Addict
- Joined
- Sep 20, 2018
- Posts
- 12
- Reaction
- 0
- Points
- 69
- Age
- 24
MGA PAPS! PA-HELP!
-
Ang problem nya kapag idididplay na nya yung EVEN may 0 sa unahan at hulihan. Paano ba alisin yun. Sana may maka tulong salamat po!
-
int even = 0;
int odd = 0;
int total = 0;
int x = 0;
string y = Convert.ToString(x);
string z = Convert.ToString(x);
int i = 1;
Console.WriteLine("Please enter integers: Press 0 to exit..");
do
{
x=int.Parse(Console.ReadLine());
if(x%2==0)
{
even+=x;
y = y + " " + x; -------//Heto yung sinasabi ko.
}
else
{
odd+=x;
z = z +" "+x;
}
i++;
}while(x != 0);
Console.WriteLine("Series of Even: " + y);
Console.WriteLine("Sum of Even: " + even);
Console.WriteLine("Series of Odd: " + z);
Console.WriteLine("Sum of Odd: " + odd);
Console.WriteLine("Sum of all series: "+ (total=even+odd));
-
SAMPLE RUN:
Please enter integers: Press 0 to exit..
1
2
3
4
5
0
Series of Even: 0 2 4 0 <<<------ ayan bakit po may 0 pa?
Sum of Even: 6
Series of Odd: 1 3 5 0 <<<------ ayan may zero pa po sa huli?
Sum of Odd: 9
Sum of all series: 15
-
Ang problem nya kapag idididplay na nya yung EVEN may 0 sa unahan at hulihan. Paano ba alisin yun. Sana may maka tulong salamat po!
-
int even = 0;
int odd = 0;
int total = 0;
int x = 0;
string y = Convert.ToString(x);
string z = Convert.ToString(x);
int i = 1;
Console.WriteLine("Please enter integers: Press 0 to exit..");
do
{
x=int.Parse(Console.ReadLine());
if(x%2==0)
{
even+=x;
y = y + " " + x; -------//Heto yung sinasabi ko.
}
else
{
odd+=x;
z = z +" "+x;
}
i++;
}while(x != 0);
Console.WriteLine("Series of Even: " + y);
Console.WriteLine("Sum of Even: " + even);
Console.WriteLine("Series of Odd: " + z);
Console.WriteLine("Sum of Odd: " + odd);
Console.WriteLine("Sum of all series: "+ (total=even+odd));
-
SAMPLE RUN:
Please enter integers: Press 0 to exit..
1
2
3
4
5
0
Series of Even: 0 2 4 0 <<<------ ayan bakit po may 0 pa?
Sum of Even: 6
Series of Odd: 1 3 5 0 <<<------ ayan may zero pa po sa huli?
Sum of Odd: 9
Sum of all series: 15