SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Develop a C program that computes X raised to the power n, X^n, recursively. In a nut shell,
input: X is a real number and n is an integer.
Program output: X is raised to the power n. Should alert the user if a negative exponent is
entered, to enter positive ONLY
Solution
/* C Code to determine computes X raised to the power n using recursive function */
#include <stdio.h>
// recursive power function
double power(double base,int exponent)
{
if(exponent == 0) return 1;
if ( exponent!=1 )
// multiply base exponenet times recursively
return (base*power(base,exponent-1));
}
int main()
{
double X;
int n;
// taking input base and exponent
printf("Enter base number(real number): ");
scanf("%lf",&X);
printf("Enter exponent(positive integer): ");
scanf("%d",&n);
// checking if exponenet is negative
// the take input again
while(n < 0)
{
printf(" Invalid input ");
printf("Enter positive exponent ONLY  ");
printf("Enter exponent: ");
scanf("%d",&n);
}
// calling the power function
printf("%lf^%d = %lf ", X, n, power(X, n));
return 0;
}
/*
Output:
Enter base number(real number): 3
Enter exponent(positive integer): 3
3.000000^3 = 27.000000
Enter base number(real number): 10
Enter exponent(positive integer): 2
10.000000^2 = 100.000000
Enter base number(real number): 10.1
Enter exponent(positive integer): 0
10.100000^0 = 1.000000
Enter base number(real number): 101.2
Enter exponent(positive integer): 2
101.200000^2 = 10241.440000
Enter base number(real number): 10.5
Enter exponent(positive integer): -2
Invalid input
Enter positive exponent ONLY
Enter exponent: -2
Invalid input
Enter positive exponent ONLY
Enter exponent: 0
10.500000^0 = 1.000000
*/

Weitere ähnliche Inhalte

Ähnlich wie Develop a C program that computes X raised to the power n- X^n- recurs.docx

Ähnlich wie Develop a C program that computes X raised to the power n- X^n- recurs.docx (11)

UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
 
7 functions
7  functions7  functions
7 functions
 
Dti2143 chapter 5
Dti2143 chapter 5Dti2143 chapter 5
Dti2143 chapter 5
 
Funções, Scanf, EOF
Funções, Scanf, EOFFunções, Scanf, EOF
Funções, Scanf, EOF
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of Recursion
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C code examples
C code examplesC code examples
C code examples
 
C++ Language
C++ LanguageC++ Language
C++ Language
 

Mehr von rtodd615

Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docx
Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docxDiscuss reaction strategies to handle Malware-SolutionMalware- Malware.docx
Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docxrtodd615
 
Discuss the differences between a form and a report- What characterist.docx
Discuss the differences between a form and a report- What characterist.docxDiscuss the differences between a form and a report- What characterist.docx
Discuss the differences between a form and a report- What characterist.docxrtodd615
 
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docx
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docxDQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docx
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docxrtodd615
 
Discuss in scholarly detail implications of any considerations that sh.docx
Discuss in scholarly detail implications of any considerations that sh.docxDiscuss in scholarly detail implications of any considerations that sh.docx
Discuss in scholarly detail implications of any considerations that sh.docxrtodd615
 
Does adding debt increase or decrease the flexibility of a healthcare.docx
Does adding debt increase or decrease the flexibility of a healthcare.docxDoes adding debt increase or decrease the flexibility of a healthcare.docx
Does adding debt increase or decrease the flexibility of a healthcare.docxrtodd615
 
Discuss the difference between Financial Accounting and Managerial Acc (1).docx
Discuss the difference between Financial Accounting and Managerial Acc (1).docxDiscuss the difference between Financial Accounting and Managerial Acc (1).docx
Discuss the difference between Financial Accounting and Managerial Acc (1).docxrtodd615
 
Distinguish between individual barriers and organizational barriers to.docx
Distinguish between individual barriers and organizational barriers to.docxDistinguish between individual barriers and organizational barriers to.docx
Distinguish between individual barriers and organizational barriers to.docxrtodd615
 
Discussion Topic 1- Internal control consists of the policies and proc.docx
Discussion Topic 1- Internal control consists of the policies and proc.docxDiscussion Topic 1- Internal control consists of the policies and proc.docx
Discussion Topic 1- Internal control consists of the policies and proc.docxrtodd615
 
Discuss the tools and technologies for collaboration and teamwork that.docx
Discuss the tools and technologies for collaboration and teamwork that.docxDiscuss the tools and technologies for collaboration and teamwork that.docx
Discuss the tools and technologies for collaboration and teamwork that.docxrtodd615
 
Discuss the statement of cash flows Values Limitations This relates to.docx
Discuss the statement of cash flows Values Limitations This relates to.docxDiscuss the statement of cash flows Values Limitations This relates to.docx
Discuss the statement of cash flows Values Limitations This relates to.docxrtodd615
 
discuss the role of nanotechnology in today-'s information age-Solutio.docx
discuss the role of nanotechnology in today-'s information age-Solutio.docxdiscuss the role of nanotechnology in today-'s information age-Solutio.docx
discuss the role of nanotechnology in today-'s information age-Solutio.docxrtodd615
 
Discuss the reasons for the growing interest in and availability of hi.docx
Discuss the reasons for the growing interest in and availability of hi.docxDiscuss the reasons for the growing interest in and availability of hi.docx
Discuss the reasons for the growing interest in and availability of hi.docxrtodd615
 
Discuss the nature of Greek theater and the purpose it served in Ancie.docx
Discuss the nature of Greek theater and the purpose it served in Ancie.docxDiscuss the nature of Greek theater and the purpose it served in Ancie.docx
Discuss the nature of Greek theater and the purpose it served in Ancie.docxrtodd615
 
Discuss the impact of a strong culture on organization and managersSol.docx
Discuss the impact of a strong culture on organization and managersSol.docxDiscuss the impact of a strong culture on organization and managersSol.docx
Discuss the impact of a strong culture on organization and managersSol.docxrtodd615
 
Discuss the advantage and disadvantage of supporting links to files th.docx
Discuss the advantage and disadvantage of supporting links to files th.docxDiscuss the advantage and disadvantage of supporting links to files th.docx
Discuss the advantage and disadvantage of supporting links to files th.docxrtodd615
 
Discuss how engineers and risk experts view and deal with risks- (Appr.docx
Discuss how engineers and risk experts view and deal with risks- (Appr.docxDiscuss how engineers and risk experts view and deal with risks- (Appr.docx
Discuss how engineers and risk experts view and deal with risks- (Appr.docxrtodd615
 
Discuss how complementary social- managerial- and organizational asset.docx
Discuss how complementary social- managerial- and organizational asset.docxDiscuss how complementary social- managerial- and organizational asset.docx
Discuss how complementary social- managerial- and organizational asset.docxrtodd615
 
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docx
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docxdifference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docx
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docxrtodd615
 
Effective managers stay abreast of current HR topics- Some relevant is.docx
Effective managers stay abreast of current HR topics- Some relevant is.docxEffective managers stay abreast of current HR topics- Some relevant is.docx
Effective managers stay abreast of current HR topics- Some relevant is.docxrtodd615
 
effective managers stay abreast of current HR topics- Some relevant is (1).docx
effective managers stay abreast of current HR topics- Some relevant is (1).docxeffective managers stay abreast of current HR topics- Some relevant is (1).docx
effective managers stay abreast of current HR topics- Some relevant is (1).docxrtodd615
 

Mehr von rtodd615 (20)

Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docx
Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docxDiscuss reaction strategies to handle Malware-SolutionMalware- Malware.docx
Discuss reaction strategies to handle Malware-SolutionMalware- Malware.docx
 
Discuss the differences between a form and a report- What characterist.docx
Discuss the differences between a form and a report- What characterist.docxDiscuss the differences between a form and a report- What characterist.docx
Discuss the differences between a form and a report- What characterist.docx
 
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docx
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docxDQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docx
DQuestion 23 10 pts Explain how the de Broglie wavelength is related t.docx
 
Discuss in scholarly detail implications of any considerations that sh.docx
Discuss in scholarly detail implications of any considerations that sh.docxDiscuss in scholarly detail implications of any considerations that sh.docx
Discuss in scholarly detail implications of any considerations that sh.docx
 
Does adding debt increase or decrease the flexibility of a healthcare.docx
Does adding debt increase or decrease the flexibility of a healthcare.docxDoes adding debt increase or decrease the flexibility of a healthcare.docx
Does adding debt increase or decrease the flexibility of a healthcare.docx
 
Discuss the difference between Financial Accounting and Managerial Acc (1).docx
Discuss the difference between Financial Accounting and Managerial Acc (1).docxDiscuss the difference between Financial Accounting and Managerial Acc (1).docx
Discuss the difference between Financial Accounting and Managerial Acc (1).docx
 
Distinguish between individual barriers and organizational barriers to.docx
Distinguish between individual barriers and organizational barriers to.docxDistinguish between individual barriers and organizational barriers to.docx
Distinguish between individual barriers and organizational barriers to.docx
 
Discussion Topic 1- Internal control consists of the policies and proc.docx
Discussion Topic 1- Internal control consists of the policies and proc.docxDiscussion Topic 1- Internal control consists of the policies and proc.docx
Discussion Topic 1- Internal control consists of the policies and proc.docx
 
Discuss the tools and technologies for collaboration and teamwork that.docx
Discuss the tools and technologies for collaboration and teamwork that.docxDiscuss the tools and technologies for collaboration and teamwork that.docx
Discuss the tools and technologies for collaboration and teamwork that.docx
 
Discuss the statement of cash flows Values Limitations This relates to.docx
Discuss the statement of cash flows Values Limitations This relates to.docxDiscuss the statement of cash flows Values Limitations This relates to.docx
Discuss the statement of cash flows Values Limitations This relates to.docx
 
discuss the role of nanotechnology in today-'s information age-Solutio.docx
discuss the role of nanotechnology in today-'s information age-Solutio.docxdiscuss the role of nanotechnology in today-'s information age-Solutio.docx
discuss the role of nanotechnology in today-'s information age-Solutio.docx
 
Discuss the reasons for the growing interest in and availability of hi.docx
Discuss the reasons for the growing interest in and availability of hi.docxDiscuss the reasons for the growing interest in and availability of hi.docx
Discuss the reasons for the growing interest in and availability of hi.docx
 
Discuss the nature of Greek theater and the purpose it served in Ancie.docx
Discuss the nature of Greek theater and the purpose it served in Ancie.docxDiscuss the nature of Greek theater and the purpose it served in Ancie.docx
Discuss the nature of Greek theater and the purpose it served in Ancie.docx
 
Discuss the impact of a strong culture on organization and managersSol.docx
Discuss the impact of a strong culture on organization and managersSol.docxDiscuss the impact of a strong culture on organization and managersSol.docx
Discuss the impact of a strong culture on organization and managersSol.docx
 
Discuss the advantage and disadvantage of supporting links to files th.docx
Discuss the advantage and disadvantage of supporting links to files th.docxDiscuss the advantage and disadvantage of supporting links to files th.docx
Discuss the advantage and disadvantage of supporting links to files th.docx
 
Discuss how engineers and risk experts view and deal with risks- (Appr.docx
Discuss how engineers and risk experts view and deal with risks- (Appr.docxDiscuss how engineers and risk experts view and deal with risks- (Appr.docx
Discuss how engineers and risk experts view and deal with risks- (Appr.docx
 
Discuss how complementary social- managerial- and organizational asset.docx
Discuss how complementary social- managerial- and organizational asset.docxDiscuss how complementary social- managerial- and organizational asset.docx
Discuss how complementary social- managerial- and organizational asset.docx
 
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docx
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docxdifference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docx
difference between Gre tunnel and vpn tunneling-Solution1- VPN tunneli.docx
 
Effective managers stay abreast of current HR topics- Some relevant is.docx
Effective managers stay abreast of current HR topics- Some relevant is.docxEffective managers stay abreast of current HR topics- Some relevant is.docx
Effective managers stay abreast of current HR topics- Some relevant is.docx
 
effective managers stay abreast of current HR topics- Some relevant is (1).docx
effective managers stay abreast of current HR topics- Some relevant is (1).docxeffective managers stay abreast of current HR topics- Some relevant is (1).docx
effective managers stay abreast of current HR topics- Some relevant is (1).docx
 

Kürzlich hochgeladen

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Kürzlich hochgeladen (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

Develop a C program that computes X raised to the power n- X^n- recurs.docx

  • 1. Develop a C program that computes X raised to the power n, X^n, recursively. In a nut shell, input: X is a real number and n is an integer. Program output: X is raised to the power n. Should alert the user if a negative exponent is entered, to enter positive ONLY Solution /* C Code to determine computes X raised to the power n using recursive function */ #include <stdio.h> // recursive power function double power(double base,int exponent) { if(exponent == 0) return 1; if ( exponent!=1 ) // multiply base exponenet times recursively return (base*power(base,exponent-1)); } int main() { double X; int n; // taking input base and exponent printf("Enter base number(real number): "); scanf("%lf",&X); printf("Enter exponent(positive integer): "); scanf("%d",&n); // checking if exponenet is negative // the take input again while(n < 0) {
  • 2. printf(" Invalid input "); printf("Enter positive exponent ONLY "); printf("Enter exponent: "); scanf("%d",&n); } // calling the power function printf("%lf^%d = %lf ", X, n, power(X, n)); return 0; } /* Output: Enter base number(real number): 3 Enter exponent(positive integer): 3 3.000000^3 = 27.000000 Enter base number(real number): 10 Enter exponent(positive integer): 2 10.000000^2 = 100.000000 Enter base number(real number): 10.1 Enter exponent(positive integer): 0 10.100000^0 = 1.000000 Enter base number(real number): 101.2 Enter exponent(positive integer): 2 101.200000^2 = 10241.440000 Enter base number(real number): 10.5 Enter exponent(positive integer): -2 Invalid input Enter positive exponent ONLY Enter exponent: -2 Invalid input Enter positive exponent ONLY Enter exponent: 0 10.500000^0 = 1.000000
  • 3. */