Currently browsing tag

C Tutorial

Random number generation in CC

Random number generation in C/C++ Many programs need random number to complete their certain goal. For example, a quiz program needs random number to randomize the question number to be asked first. Likewise a dice game needs random number to select the face when it is thrown. So there are …

New Standard Flowchart of for loop

New Standard Flowchart of for loop. An ISO committee purposed a new Standard Flowchart of for loop. The previous flowchart of for loop is same as that of while loop. The new flowchart is shown below. Here initialization is the initialization of variable like A = 0 or A = …

How to setup GLUT in CodeBlocks IDE

How to setup GLUT in Code::Blocks IDE To setup a OpenGL Utility Toolkit (GLUT) in your Code::Blocks IDE, follow the following procedures. Make sure the Code::blocks IDE is installed. First of all you need to download a GLUT library. For this CLick Here Copy the glut. h in downloaded folder …

How to do Multithreading using C/C++

Multithreading is necessary for those programs which need to run two or more processes within a single program simultaneously. For example: when you play a game( say Mario)  in a computer, then you see two or more enemies are moving at the same time  or in case of Football game …

How to make a digital clock using C

How to make a digital clock using C The following code creates a digital clock using a 1 sec. delay. provides various functions to delay the time. Source Code: #include #include #include COORD coord = {0, 0}; void gotoxy (int x, int y) { coord.X = x; coord.Y = y; …

Mini project Employee record system using C

Mini project Employee record system using C The employee record system is very simple and for very beginner mini project. It is based one the menu-driven program for elementary database management. It employ all the basic technique of file handling in C. It consists of following features Writing the data …

Binary Vs Text File in C

Binary Vs Text File in C From the programming angle there are three main areas where text and binary mode files are different. These are: Handling of newlines Representation of end of file Storage of numbers Let us explore these three differences: In text mode, a newline character is converted …

Writing into and reading from a binary file in C

Writing into and reading from a binary file in C In previous example, you learn how to write and read a text file in C. If the number of fields in the structure increase, writing structures using fprintf(), or reading them using fscanf(), becomes quite clumsy. The more efficient way …

C Programming Advantages and Drawbacks of Pointers

C Programming: Advantages and Drawbacks of Pointers Advantages Pointers are more efficient in handling arrays and data tables. They can be used to return multiple values from a function via function arguments. Pointers permit references to functions and thereby facilitating passing of functions as arguments to other functions. The use …

Writing into and reading from a text file in C

Writing into and reading from a text file in C We use fprintf() and fscanf() functions to write into the file and read from file respectively. fprintf()  writes the data to the text file and fscanf() reads the data from from file. The following example illustrates the concept…. Writing into …

Sum of two matrices using two dimensional array in C

Sum of two matrices using two dimensional array in C Matrix is the perfect example of two dimensional array. It has row and column. Row represents one dimension and column represents second dimension. For example matrix[4][5], it has 4 rows, each row consisting 5 elements i.e matrix[0] has 5 elements,    …

C Programming File Handling

C Programming: File Handling The console function like printf() and scanf() have been used for input/output .This scheme is adequate if the volume of data involved in not so large or it is not necessary to store the information for further use. However, many applications may require a large amount …

C Programming Pointers

C Programming: Pointers   In the simplest term pointer is a nearly integer variable which stores a memory address of a computer which may contain other variable or even another pointer. If a variable contains address of another variable than it is said that first variable points to second. Pointer …

Difference between Arrays and Structures in C

Difference between Arrays and Structures in C Both the arrays and structures are classified as structured data types as they provide a mechanism that enable us to access and manipulate data in a relatively easy manner. But they differ in a number of ways listed in table below: Arrays Structures …