xcode - What is wrong with this simple C program? -
i learning c, , trying out programs in xcode. wrote simple programme here, , expecting right output.
// // main.c // chap_1 // // created manish giri on 6/17/14. // copyright (c) 2014 manish giri. rights reserved. // #include <stdio.h> #define pi 3.14159265 int main(int argc, const char * argv[]) { // insert code here... // printf("hello, world!\n"); float radius, diameter, area, circumference; printf("\n come in diameter of circle\n"); scanf("%f",&diameter); radius=diameter/2.0; circumference= 2.0*pi*radius; area=pi*(radius)*(radius); printf("\n area of circle is: %.2f\n", area); printf("\n circumference of circle is: %.2f\n", circumference); homecoming 0; } when run in xcode, , seek give input-
enter diameter of circle 6 i pop-up xcode, saying- chap_1 exited unexpectedly , lost connection. , then, @ bottom of screen output pane is, see program ended exit code: -1
what doing wrong here? don't find amiss in program. because did not initialize variables 0 @ beginning? if that's reason, why required?
many help.
update-
here's screenshot of programme running on xcode(5.0.2) on imac
nothing wrong program. wrong while come in input , press "enter" key , scanf not able interpret properly. similar known issue: xcode: lost connection error code -1
can check 1 time after removing scanf programme if giving same error.
c xcode
No comments:
Post a Comment