SAMAYA KHAN

SAMAYA KHAN

  • NA
  • 52
  • 1.7k

program asked in siemens interview

Mar 6 2018 9:48 PM
write a function which is returning an array-
suppose function like below -
int[] sum(int i) 
{
- write login here for the below output 
 
when we are calling function 1st time with parameter value as -
i = 1
o/p will be -  {1}
when we are calling function 2nd time with parameter value as -
i = 3
o/p will be  - {1,3} 
when we are calling the  function 3rd time with parameter value as -
i = 8
o/p will be like - {1,3,8}
and so on...
 
How to write a logic for this without using any in-built function.
 
Thanks in Advance.. 
 
 

Answers (2)