2. Display the longest word in the given sequence of words.
11. Given a one-dimensional array. Identify the elements of an array that are prime numbers.
2. Create a program that identifies the first 10 prime numbers.
9. A four-digit number is given. Determine if there are 3 digits in this number.
Exceptions:
1. Create a situation where an exception will occur
2. Create a situation where an exception will occur, and catch the exception.
3. Create a situation where an exception will occur, and catch the exception, the display a custom message.
4. Create a situation where an exception will occur, and catch the exception, then display the caught exception’s internal message.
5. Write code utilize the finally block
6. Create a situation where an exception will occur, and pass the exception to be handled up the chain.
7. Create a situation where no exception will occur, but generate an exception anyway.
This is my current try catch statement. I dont know why it exists when empty file read in:
// convert each string into an integer and store in "eachInt[]"
string fileContents = System.IO.File.ReadAllText(fileName);
string[] eachString = fileContents.Split(new char[] { '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
int[] eachInt = new int[eachString.Length];
try
{
for (int i = 0; i < eachString.Length; i++)
{
if (IsNumeric(eachString[i]))
{
eachInt[i] = int.Parse(eachString[i]);
}
// else
//{
// continue;
//}
}
eachInt = eachInt.Where(val => val != 0).ToArray();
}
catch(IndexOutOfRangeException)
{
MessageBox.Show("File contained no integers, try a different file.");
return;
}
Exceptions:
1. Create a situation where an exception will occur
2. Create a situation where an exception will occur, and catch the exception.
3. Create a situation where an exception will occur, and catch the exception, the display a custom message.
4. Create a situation where an exception will occur, and catch the exception, then display the caught exception’s internal message.
5. Write code utilize the finally block
6. Create a situation where an exception will occur, and pass the exception to be handled up the chain.
7. Create a situation where no exception will occur, but generate an exception anyway.
Make a function that accepts 2 numbers. It will then print a X number of row of *, and Y number of column of *, based on the numbers we input.
Make a function that takes 2 integer and lists out all the numbers from the 1st number until the 2nd number
Write a program which produces the given sequences numbers (in alternate arrangement and reverse order of the problem no. 2) using the three
looping statements: 5, 1, 4, 2, 3, 3, 2, 4, 1, 5,
1st Solution – using for loop
2nd Solution – using while loop
3rd Solution-‐ using do while loop