Special Programs in C − Calculating Power of an Integer

preview_player
Показать описание
C Programming & Data Structures: C Program for calculating the power of an integer.
Topics discussed:
1) C program for calculating the power of an integer with a positive exponent.
2) C program for calculating the power of an integer with a negative exponent.

Music:
Axol x Alex Skrindo - You [NCS Release]

#CProgrammingByNeso #CProgramming #PowerOfIntegerProgram
Рекомендации по теме
Комментарии
Автор

What a coincidence today teacher said to me solve this question as homework
And after coming home when I open YouTube and watching comedy videos for mind fresh when I scrolled down then saw that this video is recommended me
I am very happy.
My teacher said me write program only positive power but I also know how to find out power of negative.

Thank you so much

info_man
Автор

what if we just use already defined power function ""result=pow(x, y)"==x^y

mrunalshende
Автор

You are the best teacher ever ana ever no one can beat you in this field keep rock sir all the best

madhavikatta
Автор

Thank you Neso Academy I was looking for that...😊

mayankjadhav
Автор

use double data instead of int for power1 variable because int has more range
for those people who want the power for large base and exponent
if you want max power for extremely large base and exponent
use long double
the order int<long int <float<double<long double.

AMFitSpark
Автор

As usually another awesome video sir...

gopichowdary
Автор

int main()
{

int base, exp, power;
printf("Enter the base: ");
scanf("%d", &base);
printf("Enter the exp: ");
scanf("%d", &exp);
power = pow(base, exp);
printf("The value is: %d", power);
return 0;
}

aliadel
Автор

U are an amazing one thanks for ur support

hlmeyknebrayebgdi
Автор

firstly
thank you for your effort, you deserve all the best
i think one condition is missed " x to the power of zero "
i tried to find it out

#include<stdio.h>
int main()
{
int power =1, base, exponent, expo ;
double power1 = 1.0;
printf("enter base \n");
scanf_s("%d", &base);
printf("enter exponent \n");
scanf_s("%d", &exponent);
expo = exponent;

if (exponent >= 0)
{
exponent = exponent + 1;
for (exponent; exponent != 0; exponent--)
{
power = base * power ;
}
power = power / base;
printf("%d to the power of %d equals %d", base, expo, power);
}
else
{
for (exponent; exponent != 0; exponent++)
{
power1 = (1.0 / base) * power1;
}

printf("%d to the power of %d equals %.10f ", base, expo, power1);
}
}

mohamedkhawaga
Автор

Sir, if exponent ==0, then the result would be simply 1 for all the should we not add it to the code as well?

sreemoyeepradhan
Автор

Please upload some videos for 'Design and Analysis of Algorithms(DAA)'.

vaibhuuanand
Автор

You could have simply used pow(a, b), where a is base and b is the exponent.

namaychopra
Автор

What if i include <math.h> then use the power function pow(base, exponent)

kakabraza
Автор

Hi sir, Will this code work for fractional powers?

RAJ
Автор

#include<stdio.h>
int main(){
int base, expo, p=1;
printf("Base\n");
scanf("%d", &base);
printf("Enter expo\n");
scanf("%d", &expo);
if(expo>0){
while(expo!=0){
p=p*base;
expo--;
}
}
printf("%d", p);
}
it can also be done by this method:)

PragatiBatra-pdul
Автор

make avideo about pointers and structure in c program

ehabtalaat
Автор

sir Tell me How should I think like U bz you are very clear in programming!
Means How do you think programming!

ajmalkhaniit
Автор

Why did this man get only few likes...this channel worth of million likes..
Oh..I forgot it..he loves his passion.. when ever a girl post a tik tok video she will get million likes 😅😅

Nb: please avoid the grammer mistakes

aravindks
Автор

Sir if exponent=0 then will these code work for it for ex.base=2 and exponent=0

harshalkamble
Автор

what about float exponentials? can u write a program for that too pls??

jacklaughter