- 2

what is output

static int calc(int from, int to, int step=1) { int res=0; for(int i=from;i<to;i+=step) { res += i; } return res; } static void Main(string[] args) { int res = ( 2, 99, 5); Console.WriteLine(res); }

5th Oct 2016, 6:55 PM
Abdu Almamary
Abdu Almamary - avatar
6 Respostas
+ 1
there is an error
5th Oct 2016, 8:28 PM
Ashraf Ali Mohammed Naji Sinan
Ashraf Ali Mohammed Naji Sinan - avatar
+ 1
static int calc(int from, int to, int step=1) { int res=0; for(int i=from;i<to;i+=step) { res += i; } return res; } static void Main(string[] args) { int res = calc ( step: 2, to: 99, from: 5); Console.WriteLine(res); }
4th Feb 2018, 9:09 PM
Mesut Alcicek
Mesut Alcicek - avatar
0
990 after correction
5th Oct 2016, 9:08 PM
Ashraf Ali Mohammed Naji Sinan
Ashraf Ali Mohammed Naji Sinan - avatar
0
Call the method using named arguments with the values 5 for "from", 99 for "to" and 2 for "step": static int calc(int from, int to, int step=1) { int res=0; for(int i=from;i<to;i+=step) { res += i; } return res; } static void Main(string[] args) { int res = calc ( step: 2, to: 99, from: 5); Console.WriteLine(res); }
10th May 2020, 6:50 AM
Kajal Devi
Kajal Devi - avatar
0
static int calc(int from, int to, int step=1) { int res=0; for(int i=from;i<to;i+=step) { res += i; } return res; } static void Main(string[] args) { int res = calc ( step: 2, to: 99, from: 5); Console.WriteLine(res); }
26th Jun 2021, 3:52 PM
hamza elkhammy
hamza elkhammy - avatar
0
Named Arguments Call the method using named arguments with the values 5 for "from", 99 for "to" and 2 for "step": static int calc(int from, int to, int step=1) { int res=0; for(int i=from;i<to;i+=step) { res += i; } return res; } static void Main(string[] args) { int res = calc ( step: 2, to: 99, from: 5); Console.WriteLine(res); }
26th Sep 2021, 2:11 AM
YOUN Tit
YOUN Tit - avatar