This tag is associated with 350 posts

C++: Create an HTML Table

Create an HTML table. The table body should have at least three rows of three columns. Each of these three columns should be labelled “X”, “Y”, and “Z”. An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential … Continue reading »

C++: Memory Allocation

Show how to explicitly allocate and deallocate blocks of memory in your language. Show access to different types of memory (i.e., heap, stack, shared, foreign) if applicable. While the C allocation functions are also available in C++, their use is discouraged. Instead, C++ provides new and delete for memory allocation and deallocation. Those function don’t … Continue reading »

C++: Guess the Number

The task is to write a program where the program chooses a number between 1 and 10. A player is then prompted to enter a guess. If the player guess wrong then the prompt appears again until the guess is correct. When the player has made a successful guess the computer will give a “Well … Continue reading »

C++ Graphs

share on facebook tweet on twitter pin on pinterest          

C++: Write CSV File

void write_csv_file(double A[], int length, string file_name) //Function that prints array A to a *.csv file { ofstream output(file_name); for(int i = 0; i < length; i++) { output << A[i] << endl; } } share on facebook tweet on twitter pin on pinterest          

Obfuscated C Code Contest 2006. Please explain sykes2.c

How does this C program work? main(_){_^448&&main(-~_);putchar(–_%64?32|-~7[__TIME__-_/8%8][“>’txiZ^(~z?”-48]>>”;;;====~$::199″[_*2&8|_/64]/(_&2?1:8)%8&1:10);} It compiles as it is (tested on gcc 4.6.3). It prints the time when compiled. On my system: !! !!!!!! !! !!!!!! !! !!!!!! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !! !!!!!! !! !! !! !! !! !!!!!! … Continue reading »

An Introduction to the Imperative Part of C++

This document is part of the HTML publication “An Introduction to the Imperative Part of C++” The original version was produced by Rob Miller at Imperial College London, September 1996. Version 1.1 (modified by David Clark at Imperial College London, September 1997) Version 1.2 (modified by Bob White at Imperial College London, September 1998) Version … Continue reading »

C++: Radix Sort

// C++ LSD Radix Sort example, queue implementation #include <iostream.h> #include <cstdlib.h> #include <ctime.h> using std::cout; // Remove this line for older C++ compilers typedef struct slist_ { int val; struct slist_ *next; } slist; slist *radixsort(slist *L, int t) { int i, j, d, m=1; slist *temp, *head[10], *tail[10]; // Process t digits for … Continue reading »

C Programming Tips

C is one of the most important and widely used of all programming languages. It is a powerful language that can be used not only to build general-purpose applications but also to write “low-level” programs that interact very closely with the computer hardware. C lets the programmer do things that many other languages do not. … Continue reading »

Beginner’s Guide to C++

Introduction Getting Started Hello World Dissecting “Hello World” Directives Namespaces Entry Streams The Language Variables Types Operators Flow Control Functions Classes Pointers An Application Adding Tasks: Files and Vectors Listing Tasks Marking Tasks as Done Sorting Tasks: Overridden Operators and STL Algorithms Conclusion Introduction C++ is a general purpose programming language. Anyone already programming at … Continue reading »

Become a TFE Insider!