Download presentation
Presentation is loading. Please wait.
Published byMiles York Modified over 9 years ago
1
1 Advanced Programming Examples Output
2
Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i < 6; i++) for (int j = 0; j < 6; j++) { if ( i == j || i == 0 || i == 5 ) pic[i, j] = '*'; else pic[i, j] = '.'; } for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) console.write(pic[i, j]); console.writeln(“ “); } 2
3
String a = "alfred"; String b = "fred"; b = "al" + b; if (a == b) a = "fred"; else b = "fred"; 3
4
int a = 5; int b = 10; a = a + 5; { int a; a = 20; b = b + 5 ; } MessageBox.Show(a+ " " + b) } 4
5
Assume that the method enigma has been defined as follows: static int enigma(int n) { int m; while (n >= 10) { m = 0; while (n > 0) { m += n % 10; n /= 10; } n = m; } return (n); } What is the value of enigma(1999) ? 5
6
using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d == a) || (a < b+c) && (d-c <= b)); } 6
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.