Category Archives: C/C++

C/C++ demo code

C++: A Simple Command-Line Parser Add-in for Console-Based Applications


A well-structured non-trivial console-based application uses many options and variables which could be set by user in command-line. A unified way of handling the command-line options is an always-needed sub-task of programming. A good strategy for a programmer is to … Continue reading

Posted in C/C++ | Tagged , , | 2 Comments

Mixed C++/Assembly: Numeric Practice using x87 Math Coprocessor


This simple prgram demostrates the use of x87 numeric (math) coprocessor in numeric analysis. Here, the taylor expansion for sin is examined. Continue reading

Posted in Assembly, C/C++ | Tagged , , , , , | Leave a comment

Mixed C++/Assembly: A Fast Algorithm to Find the First n Prime Numbers


This demo program finds the first n prime numbers using a fast algorithm with x86 32-bit assembly language. This project has been tested with Visual Studio .Net 2008 (C++) There are two constants rows (preset to 20) and cols (preset … Continue reading

Posted in Assembly, C/C++ | Tagged , , | Leave a comment

Mixed C++/Assembly: A function to find the prime factor of a number


There has already been a function to find the lowest prime factor of a number in C/C++ language in the article A function to find the prime factor of a number in C++. This article uses the same algorithm (as … Continue reading

Posted in Assembly, C/C++ | Tagged , , , , | Leave a comment

C++: A menu-driven CSV student database


Menu-driven CSV text student database is one of the most demanding assignments. This sample demo illustrates that this project – in its simplest form – is not trivial, and still it has a lot to do to improve. Continue reading

Posted in C/C++ | Tagged , , , | 1 Comment

C++: Factorizing an Integer


This posting demonstrates a simple C++ project containing 3 files: main.cpp prime.h prime.cpp prime.cpp prime.cpp contains two library functions: getPrimeFactor() and getFactorizedString(). We have already commented about getPrimeFactor() in posting A function to find the prime factor of a number … Continue reading

Posted in C/C++ | Tagged , , | 1 Comment

Spell Number: Read out a number in C++


SpellNumber.cpp spells numbers (reads out numbers as words). Revision (2) (2) An issue found and fixed: A number like 1,994,574 would be read out like : 1,994,574 : One Million, Nine Hundred, Ninety Four Thousand, Five Hundred and Seventy Four … Continue reading

Posted in C/C++ | Tagged , | 3 Comments

Sample C I/O: Student Records


This program is very simple demo. This program: Prints the current working directory. Asks user to specify the file name containing the records of students. Reads the record from the file. Prints each record with statistics Each line in the … Continue reading

Posted in C/C++ | Tagged , , | 1 Comment

Simple text menu demo in C++


This is a sample demo: /* text-menu.cpp demp program This is a simple text menu application using C++ */ #include <iostream> #include <conio.h> using namespace std; void printMenu (); void add (int, int); void sub (int, int); void mul (int, … Continue reading

Posted in C/C++ | Tagged , | Leave a comment

A function to find the prime factor of a number in C++


This is a very simple algorithm to find the smallest prime factor of a number: A prime factor is a prime number by which a number is dividable. For example, 35 has two prime factors: 5 and 7. This function … Continue reading

Posted in C/C++ | Tagged , , | 2 Comments