Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey there, I just started my first program in years and i have a problem. Basically I started writing a construction estimation app.
i enter 1 for ht and len but it keeps showing both as "229332".
Here is the code:

C++
#include<stdio.h>


int no_brick = 0, no_block, no_hours, bl_price = 15, br_price = 400, day_w = 20, b_chce = 0, mm_sqr, m_chce;


int main()

{
	
	printf("Hi, I am going to guide you through estimating the work you want carried out. \n\n");
	printf("Just so you know this will only estimate labour costs and the amount of \nmaterials needed.\n\nIf you decide to go ahead with your build we will discuss materials wanted and \ngive you a complete price before going ahead with construction.\n\n");	
	printf("Now , what is it you want to built \n\nPlease enter a number for the correct choice as follows:\n 1 Garden or retaining wall \n 2 Extension \n 3 House \n 4 Remedial work \n\n :");
	
		scanf("%i", &b_chce);
	
    system("cls");
    
    int len;
    int ht;
    int mtr_sqr;

	switch(b_chce)
	{
		case 1 : 
			printf("Lets price your wall!\n\nYou will need the following things: \nMeasuring tape\nPen and paper\n\n");
			
			printf("Now, just measure the length the wall will be by measuring the permimeter you \nwant it so be on.\n\nNow we need the height that you want it to be, the height must be in a multiple of 75mm to work in accordance with brickwork.\n\n");
			
			printf("Now could you enter the length in metre please :");
			scanf("%i", &len);
			
			printf("\n\nAnd now enter the height also in metres please:");
			scanf("%i", &ht);
			
			printf("\nDo you want the wall built of stone or facing brick?:");
			scanf("%i", &m_chce);
			
			printf("no of brick = %i", &ht);
			
			printf("no of brick = %i", &len);
			
			mtr_sqr = len * ht;
			
			printf("no of brick = %i", &mtr_sqr);
			
			no_brick = mtr_sqr * 59;
			
			printf("no of brick = %i", &no_brick);
			
			break;
			
			
		case 2: 
			printf("Lets price your extension!");
			break;
			
		case 3:
			printf("Lets price your house!");
			break;
			
		case 4:
			printf("Lets try get you a price!");		
			break;
			
		default: 
			printf("Please enter the correct choice, thanks.");
	}
	
	getch();
	return 0;
}
Posted
Updated 19-Jan-15 10:23am
v2
Comments
[no name] 19-Jan-15 17:09pm    
This is the type of issue where the debugger is invaluable.

1 solution

I don't think you want the & in
printf("no of brick = %i", <big>&</big>ht);<br />
and the other lines.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900