You are on page 1of 8

1. Write a C# program to determine the day of the week 10 days after the current date.

Expected Output :

Today: Monday

The day of the week 10 days after today: Thursday

_____________________________________________________________________________________

2. Write a program in C# to create a function for the sum of two numbers and reuse by calling it from
main method.

Expected Output :

Function to calculate the sum of two numbers:

--------------------------------------------------

Enter the first number: 2

Enter the second number: 5

The sum of these two numbers: 7

_____________________________________________________________________________________

3. Write a program in C# to create a function to input a string and count the number of spaces within the
string.

Expected Output :

Function to count number of spaces in a string:

----------------------------------------------------

Please input a string: This is ITPEC June Intake.

"This is ITPEC June Intake." contains 4 spaces


4. Write a program in C# Sharp to calculate the sum of elements in an array.

Expected Output:

Function: Calculate the sum of the elements in an array:

---------------------------------------------------------------------------

Input 5 elements in the array:

element - 0 : 1

element - 1 : 2

element - 2 : 3

element - 3 : 4

element - 4 : 5

The sum of the elements of the array is 15

5. Write a C# program to create a function to swap two integer numbers.

Expected Output:

Function: To swap the values of two integer numbers:

----------------------------------------------------------

Enter the 1st number: 45

Enter the 2nd number: 65

After swapping,

The 1st number: 65

The 2nd number: 45

_____________________________________________________________________________________
6. Write a C# program to create a function to display the n number Fibonacci sequence.

Expected Output:

Function: To display the n number Fibonacci series:

------------------------------------------------------------

Input number of Fibonacci Series : 10

The Fibonacci series of 10 numbers is :

0 1 1 2 3 5 8 13 21 34

_____________________________________________________________________________________

7. Write a C# program to compute the sum of two given integers.

If two values are the same, return the triple of their sum. Otherwise, return their differences value.

Expected Output:

Enter First value : 2

Enter Second value : 2

Output: (2+2)*3 = 12

(or)

Enter First value : 3

Enter Second value :2

Output: (3-2) = 1

_____________________________________________________________________________________

8. Write a C# program to check whether the given integer must be between 20 and 100.

Expected Output:

Input an integer: 15

False

Input an integer: 80

True

_____________________________________________________________________________________
9. Write a C# program to print odd numbers from 1 to 99 as console output. Prints one number per line.
The sample output as follows:

Expected Output:

Odd numbers from 1 to 99. Prints one number per line.

...

95

97

99

_____________________________________________________________________________________

10. Write a C# program to compute the total sum of each integer's digit value.

Expected Output:

Input a number (only integer): 12

The total sum of each integer's digit value: 3

_____________________________________________________________________________________

11. Write a C# program to reverse the words of a sentence without using Reverse () Method.

Expected Output:

Original String: Order reversed

Reverse String: reversed Order

_____________________________________________________________________________________
12. Write a C# program to find the largest and lowest values from three integer values.

Expected Output:

Input first integer: 1

Input second integer: 2

Input third integer: 3

Largest of three: 3

Lowest of three : 1

_____________________________________________________________________________________

13. Write a C# program to create a string where the first 4 characters are in lower case.

If the string is less than 4 characters, make the whole string in upper case.

Expected Output:

Input a string: itpec

_____________________________________________________________________________________

14. Write a C# Sharp program to read 10 numbers and find their average and sum.

Expected Output:

Read 10 numbers and calculate sum and average:

-----------------------------------------------------------------

Input the 10 numbers:

Number-1 :2

Number-2 :4

Number-3 :6

Number-4 :8

Number-5 :10

Number-6 :12

Number-7 :14

Number-8 :16
Number-9 :18

Number-10 :20

The sum of 10 numbers is: 110

The Average is: 11

_____________________________________________________________________________________

15. Write a program in C# Sharp to display a right-angle triangle with an asterisk.

The pattern like:

**

***

****

Expected Output:

Display the pattern like right-angle using asterisk:

-----------------------------------------------------------------

Input number of rows: 10

**

***

****

*****

******

*******

********

*********

**********

_____________________________________________________________________________________
17. Write a program in C# Sharp to display a pattern like a right-angle triangle with a number.

The pattern like:

12

123

1234

Expected Output:

Display the pattern as right-angle triangle using number:

--------------------------------------------------------------------------

Input number of rows: 5

12

123

1234

12345

_____________________________________________________________________________________

18. Write a C# Sharp program to display an alphabet pattern like P with an asterisk.

Expected Output:

Display the pattern like 'P' with an asterisk:

---------------------------------------------------------

****

* *

* *

****

_____________________________________________________________________________________
19. Write a C Sharp program to display an alphabet pattern like ‘Z’ with an asterisk.

Expected Output:

Display the pattern like 'Z' with an asterisk:

--------------------------------------------------------

*******

*******

_____________________________________________________________________________________

20. Write a C# program to output the name and age attributes of the Student class with data hiding
(encapsulation) feature and the sample output in console as follows:

Expected Output:

Sample Output:

Name: James

Age: 21

_____________________________________________________________________________________

You might also like