11. Write a program to find the longest word in a hardcoded sentence.
Required Input:
Sentence: "The quick brown fox jumps over the lazy dog"
Expected Output:
Longest Word: jumps
Code In C#
using System;
class LongestWordFinder
{
static void Main()
{
// Find the longest word in the sentence
}
}
Run Code?
Click Run Button to view compiled output
12. Create a program to reverse the words in a hardcoded sentence while keeping their order.
Required Input:
Sentence: "C# programming is fun"
Expected Output:
Reversed Sentence: #C gnimmargorp si nuf
Code In C#
using System;
class ReverseWords
{
static void Main()
{
// Reverse each word in the sentence
}
}
Run Code?
Click Run Button to view compiled output
13. Write a program to check if a hardcoded number is an Armstrong number.
Required Input:
Number: 153
Expected Output:
Is Armstrong Number: True
Code In C#
using System;
class ArmstrongCheck
{
static void Main()
{
// Check if the number is an Armstrong number
}
}
Run Code?
Click Run Button to view compiled output
14. Create a program to find all pairs in a hardcoded array that sum up to a hardcoded target.
Required Input:
Array: [1, 2, 3, 4, 5], Target: 6
Expected Output:
Pairs: [1, 5] [2, 4]
Code In C#
using System;
class FindPairs
{
static void Main()
{
// Find all pairs that sum to the target
}
}
Run Code?
Click Run Button to view compiled output
15. Write a program to calculate the transpose of a hardcoded 2D array.
Required Input:
Matrix:
[ [1, 2, 3],
[4, 5, 6],
[7, 8, 9] ]
Expected Output:
Transposed Matrix:
1 4 7
2 5 8
3 6 9
Code In C#
using System;
class TransposeMatrix
{
static void Main()
{
// Calculate the transpose of the matrix
}
}
Run Code?
Click Run Button to view compiled output
16. Create a program to calculate the average length of words in a hardcoded sentence.
Required Input:
Sentence: "C# is a great programming language"
Expected Output:
Average Word Length: 4.83
Code In C#
using System;
class AverageWordLength
{
static void Main()
{
// Calculate the average length of words in the sentence
}
}
Run Code?
Click Run Button to view compiled output
17. Create a program to calculate the average length of words in a hardcoded sentence.
Required Input:
Sentence: "C# is a great programming language"
Expected Output:
Average Word Length: 4.83
Code In C#
using System;
class AverageWordLength
{
static void Main()
{
// Calculate the average length of words in the sentence
}
}
Run Code?
Click Run Button to view compiled output
18. Write a program to implement the binary search algorithm on a hardcoded sorted array.
Required Input:
Array: [1, 3, 5, 7, 9], Target: 5
Expected Output:
Element found at index: 2
Code In C#
using System;
class BinarySearch
{
static void Main()
{
// Implement binary search to find the target in the array
}
}
Run Code?
Click Run Button to view compiled output
19. Create a program to remove duplicate elements from a hardcoded array and print the unique elements.
Required Input:
Array: [1, 2, 2, 3, 4, 4, 5]
Expected Output:
Unique Elements: 1, 2, 3, 4, 5
Code In C#
using System;
using System.Collections.Generic;
class RemoveDuplicates
{
static void Main()
{
// Remove duplicate elements from the array
}
}
Run Code?
Click Run Button to view compiled output
20. Create a program to remove duplicate elements from a hardcoded array and print the unique elements.
Required Input:
Array: [1, 2, 2, 3, 4, 4, 5]
Expected Output:
Unique Elements: 1, 2, 3, 4, 5
Code In C#
using System;
using System.Collections.Generic;
class RemoveDuplicates
{
static void Main()
{
// Remove duplicate elements from the array
}
}
Run Code?
Click Run Button to view compiled output