Triac

Programming

I have recently taken up programming in C. This is a simple computer programming language used in a variety of different applications. C is a robust way of creating programs that run in the prompt window or in the terminal (UNIX). I will be posting my source code on this page for any one to have a look at and try and understand.

To program C you will need a program for typing in the code and another for compiling, alternatively you can get a program such as microsoft visual studio C++ which incorporates these two items and a whole host of other developers tools. ALternatively if you use a unix based system you just make your C file in a text editor and use the operating systems built in compiler (notes on how to do this can be found here).

For learning to program there a loads of different sources, I am currently using 'The C Programming Language' by Kernighan and Ritchie. If you have a similar book and wish to send me a free copy feel free to do so and I will have a look at it, just send me and email.

So onto the programs. I am currently studying a Electronics and Electrical Engineering degree and one of my courses is programming. So here are the programs I have writen for my course.

CD ordering program
This program is a simple one which is designed to take and input from the user as to how many cds they wish to order, the program then calculates the total cost and applies a 5% discount to orders for 10 CD's or more and charge £5 + VAT carriage on orders with a value less than £100 before VAT. This program shows how to output text and inputs, how to perform calculations and how to deal with if statements.

Triangle forming program
This program displays various rotations of the same triangle made of *'s one after another. This program shows various ways while and if statements can be used for statements could also but used but I prefer while statements.

Diamond Creating Program
This program displays a diamond made from *'s with the size of the diamond varying with the input which is an odd number under 19. This programs shows further use of loops and if statements with user inputs thrown in.

 

 

Contact Us | Triac