5 Replies - 643 Views - Last Post: 23 February 2012 - 05:51 PM Rate Topic: -----

#1 memony  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 17
  • Joined: 23-February 12

Question: you want to associate noise loudness

Posted 23 February 2012 - 02:29 PM

I HAVE TRIED MY BEST AND IM GETTING A WEIRD ERROR SAYING: RUN TIME CHECK FAILURE PLEASE HELP!
THE PROGRAM DOES SUCCEED BUT, DOES NOT RUN
P/s im using Microsoft visual studio 2010

COMP 120
Homework 5

You want to associate noise loudness measured in decibels with the effect
of the noise. The following table indicates the relationship between
noise level and human perception of noises. Write a C program that inputs
the loudness in decibels and displays the human perception of this loudness.

LOUDNESS IN dbs PERCEPTION
50 or lower quiet
51-70 intrusive
71-90 annoying
91-110 very annoying
Above 110 uncomfortable


// Homework 5.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include "stdafx.h"


int
main(void)
{
	int noise_db;
	int noise_dn;

	if (noise_db <= 50)
		printf ("%lf" "-decibel noise is quiet /n", &noise_db);
		else if(noise_dn <= 70)
			printf("%lf""-decibel noise is annoying /n", &noise_db);
			else if(noise_db <= 90)
				printf ("%lf""-decibel noise is annoying /n", &noise_db);
				else
					printf("%lf""-decibel noise is uncomfortable /n", &noise_db); 
	return (0);
}


:code:

This post has been edited by jimblumberg: 23 February 2012 - 02:42 PM
Reason for edit:: Added missing Code Tags, Please learn to use them.


Is This A Good Question/Topic? 0
  • +

Replies To: Question: you want to associate noise loudness

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4278
  • View blog
  • Posts: 13,437
  • Joined: 25-December 09

Re: Question: you want to associate noise loudness

Posted 23 February 2012 - 02:44 PM

Where are you assigning values to noise_db and noise_dn?


Jim
Was This Post Helpful? 0
  • +
  • -

#3 michael072  Icon User is offline

  • D.I.C Head

Reputation: 24
  • View blog
  • Posts: 103
  • Joined: 08-February 11

Re: Question: you want to associate noise loudness

Posted 23 February 2012 - 02:48 PM

If I were you I wouldn't bother with the precompiled header unless you're going to need it. When you create a new project in VS you should check the box that says create empty project so you don't have any of that stuff in there then you can get rid of the #include "stdafx.h". Also you're calling the variable noise_db without assigning it a value so if you do int noise_db = 56 (or any number) you should be good.
Was This Post Helpful? 0
  • +
  • -

#4 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: Question: you want to associate noise loudness

Posted 23 February 2012 - 02:49 PM

Quote

Write a C program that inputs the loudness in decibels ...


Where is your program doing any input?
Was This Post Helpful? 0
  • +
  • -

#5 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: Question: you want to associate noise loudness

Posted 23 February 2012 - 03:23 PM

Since you haven't responded in a half-hour it seems you are still not getting the point.

You said "THE PROGRAM DOES SUCCEED BUT, DOES NOT RUN". By "succeed" you must mean that you were able to compile the program. That just means there are no syntax errors -- it is all "legal" C code. The problem is that you have a very critical logical error -- you're trying to make the program do something based on some value that the user will input, but you didn't write any code to get input from the user.

So it actually does run -- but it crashes or just produces no output because it is trying to use some values that don't exist.

Here's a hint: you must have seen something about the function scanf in your lectures and in your textbook. Review your book and your notes and see if you can do something with that.

This post has been edited by r.stiltskin: 23 February 2012 - 03:25 PM

Was This Post Helpful? 0
  • +
  • -

#6 memony  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 17
  • Joined: 23-February 12

Re: Question: you want to associate noise loudness

Posted 23 February 2012 - 05:51 PM

Hey everyone thank you for your kind assistance!! It helped! Thank you alot :)
I have completed the code and figured I have alot of errors "I simply started all over"
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1