Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
October 19, 2017, 11:06:15 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Why is this program exiting before waiting for character input?  (Read 3139 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:  

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 ゥ 2009 classroomM.com. All rights reserved.