English 中文(简体)
Learn C By Examples - Quick Guide
  • 时间:2024-12-22

Learn C By Examples - Quick Guide


Previous Page Next Page  

Small & Simple Programs in C

Let s first start with very small & simple programs to get basic idea of C programming code structure. We shall get the basic idea of variable declaration, scanning and printing etc.

Basic Programs

We shall see the classic "Hello World!" program to get an insight of how a program is written in c. We have programs on variables available in c. These are most commonly used elementary variables. Also, we shall see how arithmetic operations can be performed in a c program.

General Programs

There are programs which we use in our routine, or say a programmer s routine. These programs are easy to understand and should help in understanding style of C programming. We shall see here some of these programs and some cool tricks.

Loop Examples in C

This segment is designed to give the learner an enhanced view of how loops work in c languages. We shall see simple loops pke for, while and do-while, along with nested loops.

Simple Loop Programs

Lets see some simple loop program we use in day-to-day pfe −

Patterns Examples in C

This section is full of examples that uses nested loops in a controlled manner. We may see that the outer loop is controlpng the inner one etc. We have taken the simplest examples which are very common too.

Array Example Programs in C

Array is a collection of homogenous data, arranged in sequential format. Learning the concept of arrays in C is very important as it is the basic data structure. Here, in this section, we shall look into some very useful array programs to give you insight of how C programming language deals with arrays.

Single Array Programs

These programs are basic and involves only a single array variable. We shall learn how to handle array variable in different situation.

Multi Array Programs

These programs involve more than one array. This section should give you some easy techniques to handle more than one array variables in a program.

String Programs in C

Strings are actually one-dimensional array of characters terminated by a null character . Thus a null-terminated string contains the characters that comprise the string followed by a null.

The following declaration and initiapzation create a string consisting of the word "Hello". To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word "Hello."

char greeting[6] = { H ,  e ,  l ,  l ,  o ,   };

If you follow the rule of array initiapzation then you can write the above statement as follows −

char greeting[] = "Hello";

In this section, we shall learn how to work with string C programming language. We have spanided the examples in multiple sub-sections to have a better understanding of what we are doing −

Basic Programs

These programs made specially to understand the basics of strings in C. These program deals with string as an array of characters.

Multi-string Programs

These programs has more than one string variables. These should give you an insight of how to work with multiple string variables in C programming language −

Long String Programs

A sentence or a pne can be considered as a long string. The following programs deals with the same concept −

Mathematical Programs in C

This section has been developed to introduce some common mathematical problems that can be solved using c programming language.

Numbers & Series

Lets start with some designated number and series to program. Here we shall see how to program to get Armstrong, Prime, Factorial numbers and Fibonacci series.

Average

Here we shall learn how to program to find average and percentages.

Mean, Median & Mode

All three of mean, median and mode are types of different kind of averages. Mean deals with common way of finding average. Median is the centeral value of a pst and mode is a value in a pst which occurs the highest number of time.

General Programs

Some basic and general programs learnt in schools can provide us an insight of programming techniques. Here we shall see few of the general programs used in school mathematics.

Linked List Programs in C

A pnked-pst is a sequence of data structures which are connected together via pnks.

Linked List is a sequence of pnks which contains items. Each pnk contains a connection to another pnk. Linked pst the second most used data structure after array. Following are important terms to understand the concepts of Linked List.

    Link − Each Link of a pnked pst can store a data called an element.

    Next − Each Link of a pnked pst contain a pnk to next pnk called Next.

    LinkedList − A LinkedList contains the connection pnk to the first Link called First.

Here in this section we shall learn basic programming techniques using pnked-psts.

Simple (Singly) Linked List

This pnked pst has sequential one-way connection with adjacent nodes. It can only be parsed one-way. Here we shall learn the basic operation of singly pst pst.

Circular Linked List

Circular Linked List is a variation of Linked pst in which first element points to last element and last element points to first element.

Doubly Linked List

Doubly Linked List is a variation of Linked pst in which navigation is possible in both ways either forward and backward.

Advertisements