Practice 100 C# For Loop Programming Questions, TechnoVlogs

Practice 100 C# For Loop Programming Questions


Q1. Write a C# program to print the numbers from 1 to 10 using a for loop.  
  Input: None  
  Output: 1 2 3 4 5 6 7 8 9 10

Q2. Write a C# program to print the first 10 even numbers using a for loop.  
  Input: None  
  Output: 2 4 6 8 10 12 14 16 18 20

Q3. Write a C# program to print the first 10 odd numbers using a for loop.  
  Input: None  
  Output: 1 3 5 7 9 11 13 15 17 19

Q4. Write a C# program to print the multiplication table of 5 using a for loop.  
  Input: None  
  Output:  
  5 x 1 = 5  
  5 x 2 = 10  
  5 x 3 = 15  
  5 x 4 = 20  
  5 x 5 = 25  
 

Q5. Write a C# program to calculate the sum of the first 10 natural numbers using a for loop.  
  Input: None  
  Output: Sum = 55

Q6. Write a C# program to calculate the factorial of a number using a for loop.  
  Input: num = 5  
  Output: Factorial = 120

Q7. Write a C# program to print the squares of the first 10 numbers using a for loop.  
  Input: None  
  Output: 1 4 9 16 25 36 49 64 81 100

Q8. Write a C# program to print the cubes of the first 10 numbers using a for loop.  
  Input: None  
  Output: 1 8 27 64 125 216 343 512 729 1000

Q9. Write a C# program to calculate the sum of all even numbers between 1 and 50 using a for loop.  
  Input: None  
  Output: Sum = 650

Q10. Write a C# program to find the largest number in an array using a for loop.  
   Input: arr = [5, 12, 7, 3, 9]  
   Output: Largest number = 12

Q11. Write a C# program to print all the prime numbers between 1 and 100 using a for loop.  
   Input: None  
   Output: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Q12. Write a C# program to calculate the sum of all odd numbers between 1 and 50 using a for loop.  
   Input: None  
   Output: Sum = 625

Q13. Write a C# program to find the reverse of a number using a for loop.  
   Input: num = 12345  
   Output: Reverse = 54321

Q14. Write a C# program to print the first N Fibonacci numbers using a for loop.  
   Input: N = 6  
   Output: 0 1 1 2 3 5

Q15. Write a C# program to print a right-angled triangle pattern using a for loop.  
   Input: None  
   Output:  
   *  
   **  
   ***  
   ****  
   *****

Q16. Write a C# program to print a multiplication table of any number entered by the user using a for loop.  
   Input: num = 3  
   Output:     
   3 x 1 = 3  
   3 x 2 = 6  
   3 x 3 = 9  
   3 x 4 = 12  
   
Q17. Write a C# program to find the sum of digits of a number using a for loop.  
   Input: num = 123  
   Output: Sum of digits = 6

Q18. Write a C# program to print the even numbers between 1 and 100 using a for loop.  
   Input: None  
   Output: 2 4 6 8 10 12 ... 100

Q19. Write a C# program to print the odd numbers between 1 and 100 using a for loop.  
   Input: None  
   Output: 1 3 5 7 9 11 ... 99

Q20. Write a C# program to print the factorial of numbers from 1 to N using a for loop.  
   Input: N = 5  
   Output: 1 2 6 24 120

Q21. Write a C# program to calculate the sum of all the multiples of 3 and 5 below 1000 using a for loop.  
   Input: None  
   Output: Sum = 233168

Q22. Write a C# program to print a pyramid pattern using a for loop.  
   Input: None  
   Output:     
     *  
    ***  
   *****  
  *******  
   
Q23. Write a C# program to print a half-pyramid pattern using a for loop.  
   Input: None  
   Output:  
   *  
   **  
   ***  
   ****  

Q24. Write a C# program to find the sum of numbers divisible by 7 in a given range using a for loop.  
   Input: range = 1 to 100  
   Output: Sum = 735

Q25. Write a C# program to print the factors of a number using a for loop.  
   Input: num = 12  
   Output: Factors = 1 2 3 4 6 12

Q26. Write a C# program to calculate the product of all numbers from 1 to N using a for loop.  
   Input: N = 5  
   Output: Product = 120

Q27. Write a C# program to print a multiplication table in reverse order using a for loop.  
   Input: num = 4  
   Output:     
   4 x 10 = 40  
   4 x 9 = 36  
   4 x 8 = 32  
   4 x 7 = 28  
   
Q28. Write a C# program to print the sum of all numbers in an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5]  
   Output: Sum = 15

Q29. Write a C# program to print the count of numbers greater than a specific value using a for loop.  
   Input: arr = [1, 5, 10, 20], value = 5  
   Output: Count = 3

Q30. Write a C# program to find the smallest number in an array using a for loop.  
   Input: arr = [10, 20, 5, 8, 30]  
   Output: Smallest number = 5

Q31. Write a C# program to print the multiplication table for all numbers from 1 to 5 using nested for loops.  
   Input: None  
   Output:     
   1 x 1 = 1  
   2 x 1 = 2  
   3 x 1 = 3  
   4 x 1 = 4  
   5 x 1 = 5  
   
Q32. Write a C# program to print all elements of an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5]  
   Output: 1 2 3 4 5

Q33. Write a C# program to print a checkerboard pattern using a for loop.  
   Input: None  
   Output:     
   X O X O X  
   O X O X O  
   X O X O X  
   
Q34. Write a C# program to print the ASCII value of characters from 'A' to 'Z' using a for loop.  
   Input: None  
   Output: A = 65 B = 66 C = 67 ... Z = 90

Q35. Write a C# program to print the first N powers of 2 using a for loop.  
   Input: N = 5  
   Output: 1 2 4 8 16

Q36. Write a C# program to print all the divisors of a number using a for loop.  
   Input: num = 36  
   Output: Divisors = 1 2 3 4 6 9 12 18 36

Q37. Write a C# program to find the sum of squares of the first N natural numbers using a for loop.  
   Input: N = 5  
   Output: Sum of squares = 55

Q38. Write a C# program to print a reverse triangle pattern using a for loop.  
   Input: None  
   Output:  
   *****  
    ****  
     ***  
      **  
       *  

Q39. Write a C# program to calculate the sum of even digits in a number using a for loop.  
   Input: num = 123456  
   Output: Sum of even digits = 12

Q40. Write a C# program to check if a number is a perfect number using a for loop.  
   Input: num = 28  
   Output: Perfect number

Q41. Write a C# program to print all elements of a 2D array using a for loop.  
   Input: arr = [[1, 2], [3, 4], [5, 6]]  
   Output: 1 2 3 4 5 6

Q42. Write a C# program to calculate the average of numbers from 1 to N using a for loop.  
   Input: N = 5  
   Output: Average = 3.0

Q43. Write a C# program to print a diamond pattern using a for loop.  
   Input: None  
   Output:  
      *  
     ***  
    *****  
     ***  
      *  

Q44. Write a C# program to print the elements of a matrix in a spiral order using nested for loops.  
   Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]  
   Output: 1 2 3 6 9 8 7 4 5

Q45. Write a C# program to print the multiplication of two matrices using nested for loops.  
   Input:  
   Matrix A = [[1, 2], [3, 4]]  
   Matrix B = [[5, 6], [7, 8]]  
   Output:  
   [[19 22], [43 50]]

Q46. Write a C# program to calculate the sum of even numbers in an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5, 6]  
   Output: Sum = 12

Q47. Write a C# program to find the product of numbers from 1 to N using a for loop.  
   Input: N = 4  
   Output: Product = 24

Q48. Write a C# program to check if a number is a palindrome using a for loop.  
   Input: num = 121  
   Output: Palindrome

Q49. Write a C# program to find the number of vowels in a string using a for loop.  
   Input: str = "Hello World"  
   Output: Vowels = 3

Q50. Write a C# program to find the GCD (Greatest Common Divisor) of two numbers using a for loop.  
   Input: a = 56, b = 98  
   Output: GCD = 14

Q51. Write a C# program to check if a number is an Armstrong number using a for loop.  
   Input: num = 153  
   Output: Armstrong number

Q52. Write a C# program to find the LCM (Least Common Multiple) of two numbers using a for loop.  
   Input: a = 15, b = 20  
   Output: LCM = 60

Q53. Write a C# program to print a number pattern (1 to N) in a triangular shape using a for loop.  
   Input: N = 4  
   Output:     
   1  
   1 2  
   1 2 3  
   1 2 3 4  
   
Q54. Write a C# program to print the sum of numbers divisible by 3 in a given range using a for loop.  
   Input: range = 1 to 20  
   Output: Sum = 63

Q55. Write a C# program to find the sum of the digits of a number entered by the user using a for loop.  
   Input: num = 456  
   Output: Sum of digits = 15

Q56. Write a C# program to count how many times a specific element appears in an array using a for loop.  
   Input: arr = [1, 2, 2, 3, 4], element = 2  
   Output: Count = 2

Q57. Write a C# program to print a number pyramid using a for loop.  
   Input: None  
   Output:     
       1  
      121  
     12321  
    1234321  
   
Q58. Write a C# program to check if a number is a perfect square using a for loop.  
   Input: num = 16  
   Output: Perfect square

Q59. Write a C# program to find the sum of all prime numbers between 1 and 50 using a for loop.  
   Input: None  
   Output: Sum = 328

Q60. Write a C# program to find the number of words in a string using a for loop.  
   Input: str = "Hello World this is C#"  
   Output: Word count = 5

Q61. Write a C# program to print a number in reverse order using a for loop.  
   Input: num = 98765  
   Output: Reverse = 56789

Q62. Write a C# program to calculate the average of all elements in an array using a for loop.  
   Input: arr = [2, 4, 6, 8, 10]  
   Output: Average = 6.0

Q63. Write a C# program to find the minimum element in an array using a for loop.  
   Input: arr = [3, 1, 4, 1, 5]  
   Output: Minimum = 1

Q64. Write a C# program to print the sum of even numbers in a range using a for loop.  
   Input: range = 1 to 20  
   Output: Sum = 110

Q65. Write a C# program to print the Fibonacci sequence up to N terms using a for loop.  
   Input: N = 8  
   Output: 0 1 1 2 3 5 8 13

Q66. Write a C# program to check if a number is a perfect number using a for loop.  
   Input: num = 6  
   Output: Perfect number

Q67. Write a C# program to count the number of vowels and consonants in a string using a for loop.  
   Input: str = "C# Programming"  
   Output: Vowels = 4, Consonants = 10

Q68. Write a C# program to print a half-diamond pattern using a for loop.  
   Input: None  
   Output:  
    *  
   ***  
  *****  
   ***  
    *  

Q69. Write a C# program to calculate the sum of all odd numbers in an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5]  
   Output: Sum = 9

Q70. Write a C# program to calculate the power of a number using a for loop.  
   Input: base = 2, exponent = 3  
   Output: Power = 8

Q71. Write a C# program to count the number of even numbers in an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5]  
   Output: Count = 2

Q72. Write a C# program to print the reverse of a string using a for loop.  
   Input: str = "CSharp"  
   Output: Reverse = "prahS C"

Q73. Write a C# program to find the greatest common divisor (GCD) of an array using a for loop.  
   Input: arr = [12, 24, 36]  
   Output: GCD = 12

Q74. Write a C# program to find the second largest number in an array using a for loop.  
   Input: arr = [1, 3, 4, 2, 5]  
   Output: Second largest = 4

Q75. Write a C# program to print a checkerboard pattern of 0s and 1s using a for loop.  
   Input: None  
   Output:  
   0 1 0 1  
   1 0 1 0  
   0 1 0 1    

Q76. Write a C# program to find the sum of cubes of the first N natural numbers using a for loop.  
   Input: N = 3  
   Output: Sum of cubes = 36

Q77. Write a C# program to print the first N square numbers using a for loop.  
   Input: N = 4  
   Output: 1 4 9 16

Q78. Write a C# program to check if a number is even or odd using a for loop.  
   Input: num = 4  
   Output: Even

Q79. Write a C# program to find the product of even numbers between 1 and 10 using a for loop.  
   Input: None  
   Output: Product = 3840

Q80. Write a C# program to calculate the sum of squares of even numbers between 1 and 10 using a for loop.  
   Input: None  
   Output: Sum = 220

Q81. Write a C# program to print a multiplication table of a given number using a for loop.  
   Input: num = 5  
   Output:     
   5 x 1 = 5  
   5 x 2 = 10  
   5 x 3 = 15  
   5 x 4 = 20  
   5 x 5 = 25  
   
Q82. Write a C# program to calculate the factorial of a number using a for loop.  
   Input: num = 6  
   Output: Factorial = 720

Q83. Write a C# program to print the Fibonacci series up to N numbers using a for loop.  
   Input: N = 7  
   Output: 0 1 1 2 3 5 8

Q84. Write a C# program to check if a given number is a prime number using a for loop.  
   Input: num = 7  
   Output: Prime

Q85. Write a C# program to print the first N even numbers using a for loop.  
   Input: N = 5  
   Output: 0 2 4 6 8

Q86. Write a C# program to find the sum of numbers divisible by 5 in a given range using a for loop.  
   Input: range = 1 to 20  
   Output: Sum = 50

Q87. Write a C# program to calculate the number of digits in a number using a for loop.  
   Input: num = 12345  
   Output: Digits = 5

Q88. Write a C# program to find the sum of all prime numbers between 1 and 50 using a for loop.  
   Input: None  
   Output: Sum = 328

Q89. Write a C# program to check if a number is a power of 2 using a for loop.  
   Input: num = 16  
   Output: Power of 2

Q90. Write a C# program to calculate the sum of the first N natural numbers using a for loop.  
   Input: N = 5  
   Output: Sum = 15

Q91. Write a C# program to find the largest number in an array using a for loop.  
   Input: arr = [1, 3, 4, 2, 5]  
   Output: Largest = 5

Q92. Write a C# program to print all prime numbers in a given range using a for loop.  
   Input: range = 1 to 10  
   Output: 2 3 5 7

Q93. Write a C# program to find the number of vowels in a sentence using a for loop.  
   Input: str = "C# programming is fun!"  
   Output: Vowels = 7

Q94. Write a C# program to reverse an array using a for loop.  
   Input: arr = [1, 2, 3, 4, 5]  
   Output: Reversed array = [5, 4, 3, 2, 1]

Q95. Write a C# program to print the sum of squares of numbers from 1 to N using a for loop.  
   Input: N = 4  
   Output: Sum of squares = 30

Q96. Write a C# program to find the common elements between two arrays using a for loop.  
   Input: arr1 = [1, 2, 3, 4], arr2 = [3, 4, 5, 6]  
   Output: Common elements = 3 4

Q97. Write a C# program to calculate the sum of odd numbers in a given range using a for loop.  
   Input: range = 1 to 10  
   Output: Sum = 25

Q98. Write a C# program to print the reverse of each word in a sentence using a for loop.  
   Input: str = "C# programming is fun"  
   Output: #C gnimmargorp si nuf

Q99. Write a C# program to find the sum of all odd numbers between 1 and 100 using a for loop.  
   Input: None  
   Output: Sum = 2500

Q100. Write a C# program to calculate the factorial of a number using a for loop.  
   Input: num = 5  
   Output: Factorial = 120

Social Share

Bikki Singh Instructor TechnoVlogs

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!