learn c language

Finding roots of equations in C Language

#include <math.h> #include <stdio.h> int main() { float a, b, c, discriminant, root1, root2, realPart, imagPart; printf(“Enter coefficients a: “); scanf(“%f”, &a); printf(“Enter coefficients b: “); scanf(“%f”, &b); printf(“Enter coefficients c: “); scanf(“%f”, &c); discriminant = b * b – 4 * a * c; // condition for real and different roots if (discriminant > […]

Sorting in C Language

Basic Sorting Algorithms (Bubble, Insertion and Selection),

Searching in C Language

Searching in C Language has to check for an element or retrieve an element from any data structure where the data is stored. Based on the type of search operation, there are generally two algorithms defined in C:
1- Linear Search or Sequential Search, 2- Binary Search

Passing arrays to functions in C Language

If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in one of following three ways and all three declaration methods produce similar results because each tells the compiler that an integer pointer is going to be received. Similarly, you can pass multi-dimensional […]

Array of structures in C Language

Pointers to Structures You can define pointers to structures in the same way as you define pointer to any other variable − struct Books *struct_pointer; Now, you can store the address of a structure variable in the above defined pointer variable. To find the address of a structure variable, place the ‘&’; operator before the […]

Enumerated data types in C Language

The enumerated data type gives us an opportunity to invent our own data type and define what values the variable of this data type can take. This can help in making the program listings more readable, which can be an advantage when a program gets complicated when more than one programmer would be working on […]

Union in C Language

A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose. […]

Structure in C Language

Arrays allow to define type of variables that can hold several data items of the same kind. Similarly structure is another user defined data type available in C that allows to combine data items of different kinds. Structures are used to represent a record. Suppose you want to keep track of your books in a […]

Strings in C Language

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.

Character arrays in C Language

array of characters terminated by a null character ‘\0’. Thus a null-terminated string contains the characters that comprise the string followed by a null. The following declaration and initialization 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 […]

1 6 7 8 9 10 12