15,551 Topics

Member Avatar for
Member Avatar for Dave Sinkula

Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]gets(text)[/inlinecode] or [inlinecode]scanf("%s", text)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. The function [inlinecode]mygetline[/inlinecode] reads user input from the [inlinecode]stdin[/inlinecode] into a string …

Member Avatar for kedhar
0
306
Member Avatar for vicky_dev

Hey People! This program gives you all Pythagorean triplets in a given range.( Eg. ( 3,4,5) - 3^2+4^2 = 5^2 ). I've used a pointer to allocate memory to hold the squares of all numbers in the range. The program uses a function to search for element in the array.

0
216
Member Avatar for vicky_dev

This program prints the prime factors of a number. Eg. 56=2x2x2x7 .I've heard its really important and stuff.I believe it is really efficient and simple. Uses two functions : one to check if a number is prime and other to return the next prime number.

Member Avatar for bofarull
0
155
Member Avatar for letmec

This is a program to calculate the n-th root of any number. This program uses the NEWTON_RAPTION_ITERATION method for calculation. The general formula to find the n-th root of any number is : *-------------------------------* * (((n-1)/n)*x0) + (1/n)*(N/d) * *-------------------------------* where n =1,2,3............ (n-th root). x0 is First approximate root. …

Member Avatar for vegaseat
0
170
Member Avatar for anurag_pareek

In this program i had just extracted the modulo of the number given,and keep on adding it in linklist. later on,i reversed the link list and displayed the result. By:-- Anurag Pareek

Member Avatar for Kellaw
0
588
Member Avatar for anurag_pareek

VIRTUAL PIANO It's a very simple sound program , Input device is mouse. Sound function is used to produce output.Working is very simple based on seven natural freqencies.Move mouse over keys for sounds. Change range and note the difference.

0
198
Member Avatar for anurag_pareek

This is a simple balloon shooting game made in C language. In this game, there are number of balloons, a bow and arrows for shooting the balloons. The balloons rise from the lower portion of the screen. The bow is put on left side which can move up and down. …

Member Avatar for luna19
0
960
Member Avatar for Dave Sinkula

Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]scanf("%d", &n)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. The function [inlinecode]mygeti[/inlinecode] reads user input from the stdin into a string using [inlinecode]fgets[/inlinecode]. …

0
1K
Member Avatar for Dave Sinkula

This snippet shows how to use the functions [inlinecode]time[/inlinecode], [inlinecode]localtime[/inlinecode], and [inlinecode]strftimetime[/inlinecode] to pick off only the time parts for display.

0
128
Member Avatar for Dave Sinkula

Some issues with date/time calculations. [Perhaps I ought to edit this one day and better describe it.]

0
131
Member Avatar for Dave Sinkula

To check for integer overflow, you can't simply check the [i]outcome[/i] of an operation, you need to check [i]before[/i] the operation. So how do you do that? This example checks for overflow with multiplication.

0
354
Member Avatar for Dave Sinkula

This is yet another example of reversing a string. This version modifies the original, reversing the string in place. [I]See also [url=http://www.daniweb.com/code/snippet522.html]Strings: Reversal, Part 2[/url][/I].

0
612
Member Avatar for Dave Sinkula

This problem is a typical homework question. The code presented here may contain some elements that may be a little "ahead of the game" in coursework, but it presents some of the basic elements that might be used in such an exercise.

Member Avatar for Sealteam56
0
242
Member Avatar for aj.wh.ca

This is a bit more tough than it sounds. well some one gave me this problem and I found this tricky not until I used recursion.

0
779
Member Avatar for vegaseat

Many of the code samples on the internet are written in Turbo C. The clrscr() function litters these samples, and even to this day people want to wipe your screen. You can use system("CLS"), but that uses a DOS command. DOS commands are with us only at the whim of …

1
720
Member Avatar for vegaseat

This program uses WinApi function SetPixel() to plot math functions y = sin(x) and y = cos(x) and y = sin(x)*cos(x) along a y-axis centered on the console screen. Make sure that gdi32.lib is included in the libraries to be linked.

Member Avatar for brale
2
291
Member Avatar for Narue

A fairly complete implementation to provide another perspective on a seemingly simple program.

Member Avatar for Ene Uran
0
144
Member Avatar for TkTkorrovi

A very rudimentary more, press enter to view next screenful of text, like with print command in ed text editor.

0
99
Member Avatar for TkTkorrovi

Similar to cat in unix textutils. You can actually edit files with these. Remember that ctrl-z sends end-of-file in windows, and ctrl-d in linux.

Member Avatar for Dani
0
101
Member Avatar for TkTkorrovi

Text fragment extractor (usage: fragment /pattern/[n] [/pattern/[n]] file), similar to the print command in ed and vi, with pattern range. If the second pattern is omitted, prints to the end of file. Use quotation marks when there are spaces in the argument. Finds the first pattern, then the second pattern, …

0
127
Member Avatar for Siersan

Unlike a balanced skip list, a probabilistic skip list uses random numbers to determine the height of each node rather than deterministic logic. The only real advantage of using a linked structure instead of an array based structure is in code maintainability.

0
103
Member Avatar for Siersan

Array based skip lists are a pain to work with. They are error prone and difficult to follow. Worse, they are difficult to extend so that the data structure is deterministic rather than probabilistic (a desirable property). The following implementation uses a linked structure instead of arrays for the levels.

0
144
Member Avatar for Dave Sinkula

In [url=http://www.daniweb.com/code/snippet149.html]Part 2[/url], you may have noticed that the bits representing the [i]value[/i] of an [font=courier new]unsigned int[/font] did not appear to match the bits representing the [i]object[/i]. This is because of the [i][url=http://en.wikipedia.org/wiki/Endianness]endianness[/url][/i] of my implementation. When it comes to displaying the bits of objects that take more space …

0
141
Member Avatar for Dave Sinkula

In [url=http://www.daniweb.com/code/snippet148.html]Part 1[/url], I chose [font=courier new]unsigned int[/font] as the type to use for displaying the bits of a value. The same general procedure can be done with other types as well. The biggest issue really is the expression which generates the most significant bit, for which there are a …

0
402
Member Avatar for Dave Sinkula

It is often instructive to display the bits of a value. (This is similar to 'converting' an integer to binary.) The way I have done this in this snippet is to start at the most significant bit and work your way through all the rest of the bits. (Continued in …

0
372
Member Avatar for Dave Sinkula

This is a very common task for a beginner programmer. Unfortunately many beginners do not seem to understand the question. First, know that binary, decimal, octal, hexadecimal, and others are simply [i]representations[/i] of values. The value of 123 (decimal) still has the same [i]value[/i] if it represented in hexadecimal (7B), …

Member Avatar for al3x748769
0
508
Member Avatar for vegaseat

Let's expand the decimal to binary converter to include, amongst others, octal and hexadecimal conversions. Also shows how to exert some input control. Simple stuff!

1
176
Member Avatar for vegaseat

Get simple information like serial number, bytes/sector, sectors/cluster, free and total disk space of your hard drive using Windows API calls.

Member Avatar for sytheron
2
151
Member Avatar for harshchandra

This program finds the solution of system of simulataneous equation Using GAUSS SEIDEL METHOD. This method is very popural among the students who studies Numerical Techniques.Though this program cant find the solution of every equations,it is widely used.This can only found the solutions of those equations which are Digonally dominant.

0
271
Member Avatar for vegaseat

What is so easy to do in HTML gets quite involved in C. Once you learn to look past the standard GUI overhead it becomes more obvious. This example shows the effect of the mouse cursor moving across a label by changing foreground and background colors.

0
192

The End.