Hi! I'm new to C programming and I can't understand what is happening. I have written some code to calculate the number of rolls of wallpaper to decorate a room. I have compiled it and at first it worked OK, using it in my C compiler program (LCC Wedit). Subsequently I tried running it by clicking on the executable and it does not run and returns code -1 instead of 0. Even if I return to the compiler program it comes up with the same return code. Why is this happening? Here is the code: Code: #include <stdio.h> #include <conio.h> int main(void) { float ht, wall1, wall2, wall3, wall4, winht, winwidth, wallarea,Wpaperwid,Wpaperarea, NoLen, NoRolls; printf("Height of wall to be wallpapered = ? "); scanf("%f", &ht); printf("Width of Wall 1 = ? "); scanf("%f", &wall1); printf("Width of Wall 2 = ? "); scanf("%f", &wall2); printf("Width of Wall 3 = ? "); scanf("%f", &wall3); printf("Width of Wall 4 = ? "); scanf("%f", &wall4); printf("Width of Window = ? "); scanf("%f", &winwidth); printf("Height of Window = ? "); scanf("%f", &winht); wallarea = ((ht*wall1)+(ht*wall2)+(ht*wall3)+(ht*wall4)-(winht*winwidth)); printf("Total area of Walls, less Window = "); printf("%f\n", wallarea); printf("Width of Wallpaper = ?"); scanf("%f", &Wpaperwid); Wpaperarea =(ht*Wpaperwid); printf("Area of one length of Wallpaper = "); printf("%f\n", Wpaperarea); printf("Number of lengths of Wallpaper = "); NoLen=(wallarea/Wpaperarea); printf("%f\n", NoLen); NoRolls=(ht*NoLen/10); printf("Number of Rolls of Wallpaper= "); printf("%f\n", NoRolls); return(0); }
Woo! Whats going on? Found a way of running program called Execute on the Utils menu and it ran and and let me input the values, but When I got to the last input and pressed enter the console closed, so I could not se the result. I think it may have written the result to the screen, but closed immediately. How do you hold the console open until you hit a key, like it did in the compiler program?