Thread: About my new program

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    About my new program

    Hello ,

    I am making a simple program for float and just want to take values from users as input.


    The program is as follows:
    ------------------------------------------------------------------------

    Code:
     #include<iostream>
     
     using namespace std;
     
     float i;
     float x=2.5;
     float y=7.5;
     
     main()
     
     {
      
      
     cout<<" pls enter a number"<< endl;
     
      cin>>i;
      
      if (i<5 && i==x)
      {
      cout<<"x=";
      
      cout<<x;  
      
      
     }
     
     else
     
     cout<<" pls enter a number either 2.5 or 7.5"<<endl;
     
     if (i<10 && i==y)
     
       {
        cout<<"i=";
        
        cout<<y;
     
     }  
     else   
      
      cout<<"pls enter either a number 2.5 or 7.5"<<endl; 
        
            
    
    system("pause");
    ----------------------------------------------------------------------

    when I compile this program using "Dev++" , it gives me an error at the bottom as:

    "no new line at the end of the file"

    Can you pls tell me what exactly is the mistake that I am doing?

    Thanks
    Last edited by student111; 11-14-2013 at 03:29 AM. Reason: correcting

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Presumably it uses some ancient version of GCC (/mingw?).
    Navigate to after the last character and press enter one or more times.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    main must have a return type of main. You are not allowed to omit the return type of a function in C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    I wasn't joking when I said you should update the compiler that comes with DevC++. The tools are fine, but the compiler is ancient.

    You could also download a maintained IDE like Code::Blocks.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-11-2012, 12:25 AM
  2. Replies: 6
    Last Post: 07-14-2012, 09:43 AM
  3. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM