Write a VB program to calculate x^y without using built-in function
Answers
Answered by
1
Explanation:
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,i,r=1,t;
printf("Enter a number:");
scanf("%d",&x);
printf("Enter the power:");
scanf("%d",&y);
for(i=1;i<=y;i++)
{
t=x;
r=r*t;
}
printf("Result:%d",r);
getch();
}
Output:
Enter a number:5
Enter the power:3
Result:125
Similar questions
Computer Science,
5 months ago
Math,
5 months ago
English,
9 months ago
Social Sciences,
9 months ago
Physics,
1 year ago
Hindi,
1 year ago
Science,
1 year ago