This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Wednesday 7 August 2013

Program to calculate the Power of a number using WHILE loop (2)

#include<stdio.h>
void main()
{
int bas, exp, a, power=1;
clrscr();
printf("Enter the value of base number: ");
scanf("%d",&bas);
printf("\nEnter the value of exponent: ");
scanf("%d", &exp);
a=exp;
while (a!=0)
{
power*=bas;
--a;
}
printf("\nThe value of %d power %d = %d", bas, exp, power);
getch();
}


No comments:

Post a Comment