﻿ C# Sharp Exercises: Function : To calculate the result of raising an integer number to another - w3resource

# C# Sharp Exercises: Function : To calculate the result of raising an integer number to another

## C# Sharp Function : Exercise-7 with Solution

Write a program in C# Sharp to create a function to calculate the result of raising an integer number to another.

Pictorial Presentation:

Sample Solution:

C# Sharp Code:

``````using System;
public class funcexer7
{
public static void Main()
{
int n1;
int exp1;
Console.Write("\n\nFunction : To calculate the result of raising an integer number to another :\n");
Console.Write("--------------------------------------------------------------------------------\n");
Console.Write("Input Base number: ");
Console.Write("Input the Exponent : ");
Console.WriteLine("So, the number {0} ^ (to the power) {1} = {2} ",n1, exp1, PowerRaising(n1, exp1));
}
public static int PowerRaising(int num, int exp)
{
int rvalue = 1;
int i;
for (i=1;i<=exp;i++)
rvalue=rvalue*num;
return rvalue;
}
}
```
```

Sample Output:

```Function : To calculate the result of raising an integer number to another :
--------------------------------------------------------------------------------
Input Base number: 8
Input the Exponent : 2
So, the number 8 ^ (to the power) 2 = 64
```

Flowchart :

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

﻿

New Content: Composer: Dependency manager for PHP, R Programming