+ 1
Multiple Parameters
namespace Calc { class Program { static void Main(string[] args) { Test(); // error is there also when i write x and y as x,y } static void Test(int x , int y) { Console.WriteLine("Please Enter 1st number"); x = int.Parse(Console.ReadLine()); Console.WriteLine("Please Enter the 2hnd Number"); y = Convert.ToInt32(Console.ReadLine()); int sum = x + y; Console.WriteLine("The sum of Given Numbers is {0} ", sum); } } } Can Anyone guide me that if i get values from user then what will i give in parameters at the time of defining in main?
2 odpowiedzi
+ 3
You are asking for user input within `Test` method. So you don't need the <x> nor <y> parameter.
The declaration of method `Test` should be plain `static void Test()` without any parameter. But pay attention to explicitly state the type for <x> and <y> within `Test` method as follows:
int x = int.Parse( ...
int y = int.Parse( ...
+ 1
for JavaScript Multiple Parameters
function main() {
var goalsTeam1 = parseInt(readLine(), 10);
var goalsTeam2 = parseInt(readLine(), 10);
finalResult(goalsTeam1, goalsTeam2)
if(goalsTeam1>goalsTeam2){
goalsTeam1 = console.log("Team 1 won");
}
else if(goalsTeam2>goalsTeam1){
goalsTeam2 = console.log("Team 2 won");
}
else{
console.log("Draw");
}
}
function finalResult() {
};