5 questions; | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

5 questions;

1. Why 34? string str = "012345" str = str.Substring(0); str = str.Substring(2); str = str.Substring(0,3); str = str.Substring(1,2); Console.Write(str); 2. Why 120? int foo = 1; for(int x = 5; x <= 50; x++) { foo *= x; for(int y = 1; y <= 5; y++) { if(x == y) goto bar; foo *= y; } } bar: Console.Write(foo); 3. Why 2? for(int i = 1; i < 5; i++) { if(i == 2) { Console.Write(i); if(i % 2 == 1) Console.Write(i); break; Console.Write(i); continue; } } 4. Why 4? static int sm(ref int a, ref double A) { --a; --A; if(a.GetType()==typeof(int)) return (int) A; return a; } static void Main(string[] args) { int A = 5; double a =-1.4; A = sm(ref A, ref a); Console.Write(Math.Abs(Math.Ceiling(A+a))); } 5. Why abab instead of baba? static void Main(string[] args) { string str = "abab"; change(str); Console.Write(str); } static void change(string s) { s = "baba"; }

8th Jan 2021, 8:25 AM
eMBee
eMBee - avatar
2 Respostas
+ 1
Im a beginner, i haven't started c# yet, so these might be wrong!! Please let me know & we will learn together. 1. Are you using an IDE like VSCode & forgetting to clear the cache between runs? 2. 20x6 3. First pass doesnt meet i = 2, 2nd pass does, 3rd pass doesnt meet i = 2 4. absolute value of (5 + (-0.7) rounded to nearest digit) 5. Scope of variables.
8th Jan 2021, 10:55 AM
HungryTradie
HungryTradie - avatar
+ 6
Mā—‹|-|FĪžY šŸ‡³šŸ‡¬ , i don't go in details about your questions. All these codes are not really complex, so by reading the codes, it should be possible to find the answers by yourself. (remember that you have finished C# course!). if you get stuck somewhere, you can use online ide "onlineGDB", use debug mode there and see what happens in each step.
8th Jan 2021, 10:55 AM
Lothar
Lothar - avatar