this is my homework for tomorrow and i don`t now how to do it
write a c++ program to output vertically ten consecutive numbers to a file. the file should be named as "yourFirstName_yourLastName".

Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
i now how to make a file but i don`t now the exact formula of writing vertical numbers in a file
Output to a file is almost the same as output to the console. Instead of cout, put the name of the output stream.
This is so trivial that basic trial and error should be able to lead you to a solution.

If you don't know how to use files read these two.

And if you don't know how to use loops read this:

If you've ever seen a for loop and know how to open a file, then you should be set to solve this problem .
Last edited on
\\ this what i wrote till now
using namespace std;

int main()
ofstream amjad_alghamdi;
string amjad_alghamdi; / Users / Amjad / Desktop / amjad_alghamdi.txt);
if (amjad_alghamdi)
cout <<
You don't need the string string amjad_alghamdi;, I suggest remove that line.

You can open the file like this:"C:/Users/Amjad/Desktop/amjad_alghamdi.txt");

Note the double quotes around the filename because it is a character string.
Topic archived. No new replies allowed.