Write a C Program to Find mn where m and n are Integers Given by User

In this tutorial learn how you can write a c program to find mn. Where m and n are integers and must be given by the user.

We are using for loop to calculate the power of the given number for this tutorial.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.


write c program to find mn where m and n are integers given by user


Write a Program to Find mn where m and n are Integers Given by User

Here is the code to find mn. Where m and n are integers and must be given by user in C programming.

#include <stdio.h> //WAP to find mn. Where m and n are integers and must be given by user.
int main()
{
    int m, n, mn = 1, i;
    printf("Enter the base:");
    scanf("%d", &m);
    printf("Enter the exponent:");
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    {
        mn = mn * m;
    }
    printf("The value of mn is %d.", mn);
    return 0;
}

Test Live At Jdoodle



Conclusion

This is how you can find mn. Where m and n are integers and must be given by user in c programming. Comment below if you like our tutorial.

0 Comments