Amazon.com Widgets Why is this program exiting before waiting for character input?
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 29, 2014, 01:40:10 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Programming in C, 3rd ed. (Stephen Kochan)
| |-+ Answers to Odd-Numbered Exercises
| | |-+ Why is this program exiting before waiting for character input?
Pages: [1] Go Down
Print
Author Topic: Why is this program exiting before waiting for character input? (Read 2337 times)
A31Chris
Newbie
*
Posts: 20


Email




on: December 05, 2010, 01:57:30 AM

Code: (Objective-C)
#include <stdio.h>

 int number,powerraise,answer,j;

long int x_to_the_n(int a,int b);

int main(void)
{
printf("Input the number:");

scanf("%i",&number);

printf("\nWhat power to raise it to?");
scanf("%i",&powerraise);

answer=x_to_the_n(number,powerraise);

printf("%i raised to the power of %i is %i",number,powerraise,answer);


getchar();
return 0;

}



long int x_to_the_n(int a,int b)
{

for(j=1;j<powerraise;j++)
{
a *=a;
}

return a;

}

Logged
A31Chris
Newbie
*
Posts: 20


Email




Reply #1 on: December 05, 2010, 11:40:01 AM

 I realize this problem is only indirectly related to the Exercises in programming in C. I just ran into it while working on one of the exercises. I'll try to post this on a general C programming forum for some help.
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.