🔒 Closed Patulong po mga master

Status
Not open for further replies.

Behelit

Eternal Poster
Pwede po bang pasagot nito, helping a friend po kanina pa po kasi nya di nasasagutan, salamat mga sir/ma'am in advance, C# Language po
 

Attachments

  • 68853F41-904D-4962-B207-F4AD1EC05868.webp
    68853F41-904D-4962-B207-F4AD1EC05868.webp
    28.3 KB · Views: 17
static void Main(string[] args)
{
int i = 0;
string str = "";
getNumber(str, i);
}

public static void getNumber(string s, int x)
{
int i;

while(x != 5)
{
Console.Write("Enter a number : ");
i = int.Parse(Console.ReadLine());
if (i <= 1 || i % 2 != 0 || i > 100)
{
Console.WriteLine("invalid input!");
getNumber(s, x);
}
else
{
s += i + " ";
getNumber(s, x + 1);
}
}
Console.WriteLine("output : " +s);
Console.ReadLine();
}

hindi ko alam kung tama yan sir. hindi ko pa natry. try mo na lang.
 
static void Main(string[] args)
{
int i = 0;
string str = "";
getNumber(str, i);
}

public static void getNumber(string s, int x)
{
int i;

while(x != 5)
{
Console.Write("Enter a number : ");
i = int.Parse(Console.ReadLine());
if (i <= 1 || i % 2 != 0 || i > 100)
{
Console.WriteLine("invalid input!");
getNumber(s, x);
}
else
{
s += i + " ";
getNumber(s, x + 1);
}
}
Console.WriteLine("output : " +s);
Console.ReadLine();
}

hindi ko alam kung tama yan sir. hindi ko pa natry. try mo na lang.
Sir di po nagana yung syntax na getNumber sa visual, baka po may other syntax na kapareho nyan na mababasa sa visual para ma get yung number ng strings? thank you po!
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 2
    Replies
  • 270
    Views
  • 2
    Participants
Last reply from:
Behelit

Trending Topics

Online now

Members online
1,237
Guests online
4,074
Total visitors
5,311

Forum statistics

Threads
2,337,974
Posts
29,301,244
Members
1,125,915
Latest member
mktrilogy
Back
Top