## Difficulties to do diamond pattern in C program

1 Floyd’s Triangle. include int main() {int rows, i, j, number = 1;printf(“Enter the number of rows: “);scanf(“%d”, &rows);for (i = 1; i <= rows; i++) {for (j = 1; j <= i; ++j) {printf(“%d “, number);++number;}printf(“\n”);}return 0;} output 12 34 5 67 8 9 10 2 Pascal’s Triangle include int main() {int rows, coef […]

## C program to create, initialize and access a pointer variable

In this tutorial, we will write a C program to create, initialize and access a pointer variable. To learn the basics of pointer refer my tutorial: C Pointers Example: Program to create, access and initialize a Pointer In the following program we have declared a character variable ch and character pointer pCh, later we initialized the pointer variable pCh with the […]

## C Program to Swap two numbers using Pointers

In this tutorial we will write a C program to swap two numbers using Pointers. We have already covered how to swap two numbers without using pointers. C Example to swap two numbers using pointers #include <stdio.h> // function to swap the two numbers void swap(int *x,int *y) { int t; t = *x; *x = […]

## C Program to Print String using Pointer

In this tutorial, we will write a C program to print a String character by character using a pointer variable. To understand this program you should have basic knowledge of the following topics: C Pointers C Array Program to print a String using Pointer In the following program we have declared a char array to […]

## C Program to Count Vowels and Consonants in a String using Pointer

In this tutorial, we will write a C program to count vowels and consonants in a given String using Pointer. To understand this program you should know the basics of Arrays and pointers in C. Program to count Vowels and Consonants in String using Pointer In the following program we have declared a char array str to hold the input […]

## C Program to Find the Largest of three numbers using Pointers

In this tutorial, we will write a C program to find the largest of three input numbers using pointers. Program to find largest number using pointers In the following program we have three integers num1, num2 & num3. We have assigned the addresses of these three numbers to three pointers p1, p2 & p3 respectively. Later we performed the comparison on the values stored […]

## Quicksort program in C

Quicksort is a divide and conquer algorithm. The steps are: 1) Pick an element from the array, this element is called as pivot element. 2) Divide the unsorted array of elements in two arrays with values less than the pivot come in the first sub array, while all elements with values greater than the pivot […]

## Selection Sort Program in C

In Selection sort, the smallest element is exchanged with the first element of the unsorted list of elements (the exchanged element takes the place where smallest element is initially placed). Then the second smallest element is exchanged with the second element of the unsorted list of elements and so on until all the elements are […]

## Insertion Sort Program in C

Insertion sort algorithm picks elements one by one and places it to the right position where it belongs in the sorted list of elements. In the following C program we have implemented the same logic. Before going through the program, lets see the steps of insertion sort with the help of an example.Input elements: 89 […]

## C Program for bubble sorting

Bubble sort is also known as sinking sort. This algorithm compares each pair of adjacent items and swaps them if they are in the wrong order, and this same process goes on until no swaps are needed. In the following program we are implementing bubble sort in C language. In this program user would be […]