C Program to Print Diamond Number Pattern

Write a C program to print a Diamond number pattern using for loop, while loop, and functions with an example. In the below program, we used multiple nested for loops to iterate the rows and print the numbers in a diamond shape or pattern. #include<stdio.h> int main(void) { int i, j, k, rows; printf(“Enter Diamond … Read more

C Program to Print Hollow Diamond Pattern inside a Square

Write a C Program to print a hollow diamond inside a square star pattern using for loop, while loop, and functions with custom symbols. C Program to Print Hollow Diamond Pattern inside a Square In this example, we used multiple nested for loops to iterate the rows and print the hollow diamond pattern inside a … Read more

C Program to Print Hollow Diamond Star Pattern

Write a C Program to print a hollow diamond star pattern using nested for loops, while loop, functions, and if-else statements. In this C hollow diamond example, the if statement checks for outer lines and prints stars otherwise, it prints empty spaces to get that hollow shape. #include<stdio.h> int main(void) { int i, j, k, … Read more

Star Pattern Programs in C

This article shows the list of available Star Pattern Programs in C programming language with an example of each using the for loop, while loop, functions, and do while loop. Apart from the Star Pattern Programs, you can print Alphabet and Number patterns using the C programming language. Before you start reading this, I suggest … Read more

C Program to Left Rotate Array Items

Write a C program to left rotate array items for a given number of times using a for loop. This C example allows the user to enter the number of times the array has to left rotate, size, and elements. #include<stdio.h> void PrintArray(int a[], int Size) { for(int i = 0; i < Size; i++) … Read more

C program to Find the Sum and Average of Three Numbers

Write a C program to find the sum and average of three numbers. This C example accepts three integer values and calculates the sum and average of those values. #include <stdio.h> int main() { int num1, num2, num3, sum; float avg; printf(“Enter the First Number = “); scanf(“%d”,&num1); printf(“Enter the Second Number = “); scanf(“%d”,&num2); … Read more

C Program to Reverse a String using Recursion

Write a C program to reverse a string using recursive functions or recursion. In this string example, the stringReverse function accepts the pointer and reverses the character array by calling the function recursively. #include <stdio.h> #include <string.h> void stringReverse(char *Str) { if(*Str) { stringReverse(Str + 1); printf(“%c”, *Str); } } int main() { char Str[100]; … Read more

C Program to Remove Characters in a String Except Alphabets

Write a C program to remove characters in a string except for alphabets. The for loop iterates the string characters, and the if statement looks for non-alphabets. If true, we skip that character to remove all the string letters except the alphabets. #include <stdio.h> #include <string.h> int main() { char strAlphas[100]; printf(“Enter A String to … Read more