0% found this document useful (0 votes)
64 views

1 - C# FundamentalsLanguage - Exercises

This document contains instructions for 12 exercises to write C# programs that perform various calculations and string manipulations. The exercises include: 1) dividing numbers, 2) evaluating expressions, 3) arithmetic on user input, 4) calculating averages, 5) reversing numbers, 6) reversing arrays, 7) separating odd and even numbers into arrays, 8) inserting into arrays, 9) removing characters from strings, 10) swapping first and last string characters, 11) finding longest words, and 12) reversing words in sentences.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

1 - C# FundamentalsLanguage - Exercises

This document contains instructions for 12 exercises to write C# programs that perform various calculations and string manipulations. The exercises include: 1) dividing numbers, 2) evaluating expressions, 3) arithmetic on user input, 4) calculating averages, 5) reversing numbers, 6) reversing arrays, 7) separating odd and even numbers into arrays, 8) inserting into arrays, 9) removing characters from strings, 10) swapping first and last string characters, 11) finding longest words, and 12) reversing words in sentences.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EXERCISES – C# FUNDAMENTALS LANGUAGE

1. Write a C# program to print the result of dividing 24 into 5 on screen.


2. Create a C# program to print the result of the following operations:

 -1 + 4 * 6 
 ( 35+ 5 ) % 7 
 14 + -4 * 6 / 11 
 2 + 15 / 6 * 1 - 7 % 2 
Expected Output:
23
5
12
3

3. Write a C# Sharp program to print on screen the output of adding,


subtracting, multiplying and dividing of two numbers which will be entered
by the user.

Test Data:
Input the first number: 25
Input the second number: 4

Expected Output:
25 + 4 = 29
25 - 4 = 21
25 x 4 = 100 
25 / 4 = 6
25 mod 4 = 1

4. Write a C# Sharp program that takes four numbers as input to calculate and
print the average. Go to the editor

Test Data:
Enter the First number: 10
Enter the Second number: 15
Enter the third number: 20
Enter the four number: 30

Expected Output:
The average of 10 , 15 , 20 , 30 is: 18

5. Write a program in C# Sharp to display the number in reverse order.

Test Data : 
Input a number: 12345 

Expected Output :
The number in reverse order is : 54321

6. Write a program in C# Sharp to read n number of values in an array and


display it in reverse order.

Test Data : 
Input the number of elements to store in the array :3 
Input 3 number of elements in the array : 
element - 0 : 2 
element - 1 : 5 
element - 2 : 7

Expected Output: 
The values store into the array are: 
2 5 7 
The values store into the array in reverse are : 
7 5 2 

7. Write a programin C# Sharp to separate odd and even integers in separate


arrays.
Test Data : 
Input the number of elements to be stored in the array :5 
Input 5 elements in the array : 
element - 0 : 25 
element - 1 : 47 
element - 2 : 42 
element - 3 : 56 
element - 4 : 32 

Expected Output: 
The Even elements are: 
42 56 32 
The Odd elements are : 
25 47

8. Write a program in C# Sharp to insert New value in the array (unsorted list).

Test Data : 
Input the size of array : 4 
Input 4 elements in the array in ascending order: 
element - 0 : 1 
element - 1 : 8 
element - 2 : 7 
element - 3 : 10 
Input the value to be inserted : 5 
Input the Position, where the value to be inserted :2 

Expected Output :
The current list of the array :
1 8 7 10 
After Insert the element the new list is :
1 5 8 7 10 
9. Write a C# program remove specified a character from a non-empty string
using index of a character.

Test Data:
Fpt@university

Sample Output:
pt@university
Fptuniversity
Fpt@universit

10.Write a C# program to create a new string from a given string where the
first and last characters will change their positions

Test Data:
w3resource
Python

Sample Output:
e3resourcw
nythoP

11.Write a C# program to find the longest word in a string.

Test Data: Write a C# Sharp Program to display the following pattern using
the alphabet.
Sample Output:
following

12.Write a C# program to reverse the words of a sentence.

Sample Output:
Original String: Display the pattern like pyramid using the alphabet.
Reverse String: alphabet. the using pyramid like pattern the Display

You might also like