TECHiE TALKS

Just another techie stuff

Archive for the ‘C++’ Category

Hello World in C++

//Printing Hellow World!

#include <iostream>

int main()
{
std::cout << “Hello World! \n”;
system(“pause”);
return 0;
}
Line begins with //, indicating that the remainder of the line is a comment. Programmers insert comments to document programs and also help people read [...]

No Comments

Hello World in C++

#include // I/O library
using namespace std;
int main()
{
cout << “Hello, world!” << endl;
}
The // symbol is used as a rest-of-line comment symbol. Also, the program text can be placed in any position on the page, with white space between tokens being ignored. White space are characters such as blanks, tabs, and new lines. White space, [...]

No Comments

C++ Reading From a Text File

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
int count = 0;
ifstream FileName (“try.txt”);
if (FileName.is_open() && !FileName.eof()){
while (getline(FileName,line)){
count++;
}
}
else cout << “Error opening file!” << endl;
cout << “The number of lines in the file is ” << count << endl;
system(“pause”);
}

This program counts the number [...]

No Comments
Rss Feeds