Archive for the ‘C++’ Category

Infix to Postfix and Prefix

image from www.codeproject.com On the last day of our class for the first semester, our instructor gave us an assignment about infix, postfix and prefix.  The assignment was to create a program that converts infix equations to its postfix form and prefix form.  I search around the net and the resources are so few that it took me days to have a sample program in C.  I am not that good in C programming but I can create C++ or [...]

Continue Reading

1 Comment

Bubble Sort and Graphics.h in Dev C++

Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided to write how to use graphics.h in dev-c++.  I am expecting that you have already installed bloodshed dev-cpp on your machine.  Graphics.h is a header file found in borlan c but because of its late development devcpp is now the mostly used IDE and compiler in programming c++. Below are the steps on how to [...]

Continue Reading

18 Comments

Howto Hello World in C++

Line begins with //, indicating that the remainder of the line is a comment. Programmers insert comments to document programs and also help people read and understand them. Comments do not cause the computer to perform any action when the program is run; they are ignored by the C++ compiler and do not cause any machine-language object code to be generated. The comment Text-printing program describes the purpose of the program. A comment beginning with // is called a single-line [...]

Continue Reading

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 of lines in a text file. I used the getline function to count it. The getline function is used to [...]

Continue Reading

No Comments

Rss Feeds