-
Notifications
You must be signed in to change notification settings - Fork 0
/
SM_Array_PrintOdds.cs
38 lines (34 loc) · 1.26 KB
/
SM_Array_PrintOdds.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// author: Chris Patton
// summary: Self-made program with an added methods (.cs)
// for printing an arrays or returning arrays.
// Prints ODD NUMBERS from array in order of position.
// notes: 'print1' ref type was created within the solution
// student: Chris Patton
using System;
using System.Collections.Generic;
using System.Text;
class PrintArray
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! Here's my array: ");
PrintArray print1 = new PrintArray();
int[] intArray = new int[5] { 3, 4, 7, 9, 22 };
print1.PrintArrayInOrder(intArray);
print1.PrintArrayInReverse(intArray);
print1.PrintEvenNumbers(intArray);
print1.PrintOddNumbers(intArray);
int[] duplicateFromSomewhere = print1.GetDup(intArray);
int[] evenNumberArray = print1.ReturnEvenNumbers(intArray);
print1.ReturnOddNumbers(intArray);
}
public void PrintOddNumbers(int[] intArray)
{
for (int i = 0; i <= intArray.Length - 1; i++)
{
if (intArray[i] % 2 != 0)
{
Console.Write(intArray[i]);
}
}
}