All function programs in C# with an examples

A function or method is basically a block of statements that perform a specific task. For example, you are building an application in C# programming language and in one of your program, you need to perform the same task more than once. In such case, you have 2 options:

A) Use the same set of statements every time you want to perform the task

B) Create a function/Method to perform that task, and just call it when you need to perform that task.

Using option (B) is always a good practice and a good programmer always uses functions while writing codes in C# or any other programming language.

  1. Write a C# program to create a user define function with parameter
  2. Write a C# program to add two numbers using function
  3. Write a C# program to create a function to input a string and count number of spaces are in the string
  4. Write a C# program to find even or odd number using function
  5. Write a C# program to create a function to calculate the sum of the individual digits of a given number
  6. Write a C# program to create a function to check whether a number is prime or not
  7. Write a C# program to create a function to display the n number Fibonacci sequence
  8. Write a C# program to create a function to swap the values of two integer numbers
  9. Write a C# program to create a recursive function to find the factorial of a given number
  10. Write a C# program to Print Binary Equivalent of an Integer using Recursion

Leave a Comment