i trying find shortest , longest string value based on length , im getting stuck. of script exits after writeline. think code needs help, dont think loop can work on own. assistance appreciated.
(int = 5; <0; i++) { string[] word = new string[5]; console.writeline("type in word"); word[i] = console.readline(); int length = word[i].length; int min = word[0].length; int max = word[0].length; string maxx; string minn; if (length > max) { maxx = word[i]; console.write("shortest"); } if (length < min) { minn = word[i]; console.write("longest"); } } console.readkey(true); }
string[] word = new string[5]; (int = 0;i<= word.length ; i++) { console.writeline("type in word"); word[i] = console.readline(); } int min = word[0].length; int max = word[0].length; string maxx=""; string minn=""; (int = 0; i<=word.length ; i++) { int length = word[i].length; if (length > max) { maxx = word[i]; } if (length < min) { minn = word[i]; console.write("longest"); } } console.write("shortest:"+maxx); console.write("longest"+minn); console.readkey(true); }
accarding code write code.i hope right answer~~thanks!!!