Issues with this code
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Issues with this code

  1. #1
    Join Date
    Mar 2017
    Posts
    1

    Issues with this code

    It compiles, but no prompts show. I'm not sure whether it's complete or not either. My code is attached in a .txt file

    Here were the instructions:

    Write an interactive program whose input is a series of 5 temperatures from the user. It should write out in file tempdata.dat each temperature as well as the difference between the current temperature and the one preceding it, separated by two spaces. The difference is not output for the first temperature that is input. At the end of the program, the average temperature should be displayed for the user via cout. For example, given the input data

    34.5 38.6 42.4 46.8 51.3

    file tempdata.dat would contain

    34.5
    38.6 4.1
    42.4 3.8
    46.8 4.4
    51.3 4.5

    Use functions wherever appropriate. Be sure to use proper formatting and appropriate comments in your code. Provide appropriate prompts to the user. The output should be labeled clearly and formatted neatly.
    Attached Files Attached Files

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    18,928

    Re: Issues with this code

    Quote Originally Posted by Vasper View Post
    It compiles, but no prompts show. I'm not sure whether it's complete or not either. My code is attached in a .txt file
    ...
    Code:
    	for (int i = 0; i < 4; i++);
    This line does nothing!
    and I cancelled the further investigation after this line.
    Please learn how to debug the code and debug it to see where, how and why something goes wrong!
    https://msdn.microsoft.com/en-us/library/k0k771bt.aspx
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2017
    Posts
    37

    Re: Issues with this code

    See,firstly this line does nothing-
    Code:
    for(i=0;i<4;i++);
    Second,
    Function getnum() is defined but not implemented(used anywhere).

  4. #4
    Join Date
    Mar 2017
    Posts
    37

    Re: Issues with this code

    If you want that to work,declare and define it in main().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)