error: no input files

I have tis problem with a snippet that I wrote down textually from a book.
I'm using Code::Blocks, my OS is Ubuntu 16.04.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  // This program has literals and variables

#include <iostream>

using namespace std;

int main ()
{
    int apples;

    apples = 20;
    cout << "Today we sold" << apples << "bushels of apples. \n";
    cin >> apples;
    return 0;
}

What do you see is the problem? ppl say that it compiles well, but for me it is not the case.
thank you for your help.
So, nobody knows?
cin >> apples;

Maybe this is better :
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

using namespace std;

int main ()
{
    int apples;
    cout << "How many apples did we sell today? : "; cin >> apples;
    cout << "Today we sold" << apples << "bushels of apples. \n";

    return 0;
}
Last edited on
the thing is to assign the apples to 20 so the statement gets like that. look this is the snippet extracted from the book.

1
2
3
4
5
6
7
8
9
10
11
12
13
// This program has literals and a variable.
 #include <iostream>
 using namespace std;

 int main()
 {
int apples;

 apples = 20;
 cout << "Today we sold " << apples << " bushels of apples.\n";
 return 0;
 }


(I thought about the cin, but it shouldn't be there in the first place).

the output should be this:
Today we sold 20 bushels of apples


Topic archived. No new replies allowed.