C Programming Example

C Example for Beginners: C Program to Display its own Source Code as Output

Hits: 22 (C programming Example for Beginners) C Program to Display its own Source Code as Output In this example, you’ll learn to display source of the program using __FILE__ macro. Though this problem seems complex, the concept behind this program is straightforward; display the content from the same file you are writing the source …

C Example for Beginners: C Program to Write a Sentence to a File

Hits: 173 (C programming Example for Beginners) C Program to Write a Sentence to a File In this example, you will learn to write a sentence in a file using fprintf() statement. This program stores a sentence entered by the user in a file. #include <stdio.h> #include <stdlib.h> int main(){ char sentence[1000]; // creating file …

C Example for Beginners: C Program to Store Information of Students Using Structure

Hits: 34 (C programming Example for Beginners) C Program to Store Information of Students Using Structure In this example, you will learn to store the information of 5 students by using an array of structures. Store Information in Structure and Display it #include <stdio.h> struct student { char firstName[50]; int roll; float marks; } s[10]; …

C Example for Beginners: C Program to Add Two Complex Numbers by Passing Structure to a Function

Hits: 27 (C programming Example for Beginners) C Program to Add Two Complex Numbers by Passing Structure to a Function In this example, you will learn to take two complex numbers as structures and add them by creating a user-defined function. Add Two Complex Numbers #include <stdio.h> typedef struct complex { float real; float imag; …

C Example for Beginners: C Program to Store Information of a Student Using Structure

Hits: 31 (C programming Example for Beginners) C Program to Store Information of a Student Using Structure In this example, you will learn to store the information of a student in a structure and display them on the screen. Store Information and Display it Using Structure #include <stdio.h> struct student { char name[50]; int roll; …

C Example for Beginners: C Program to Concatenate Two Strings

Hits: 4 (C programming Example for Beginners) C Program to Concatenate Two Strings In this example, you will learn to concatenate two strings manually without using the strcat() function. As you know, the best way to concatenate two strings in C programming is by using the strcat() function. However, in this example, we will concatenate two strings …

C Example for Beginners: C Program to Remove all Characters in a String Except Alphabets

Hits: 42 (C programming Example for Beginners) C Program to Remove all Characters in a String Except Alphabets In this example, you will learn to remove all the characters from a string entered by the user except the alphabets. Remove Characters in String Except Alphabets #include <stdio.h> int main(){ char line[150]; printf(“Enter a string: “); …

C Example for Beginners: C Program to Find the Frequency of Characters in a String

Hits: 12 (C programming Example for Beginners) C Program to Find the Frequency of Characters in a String In this example, you will learn to find the frequency of a character in a string. Find the Frequency of a Character #include <stdio.h> int main(){ char str[1000], ch; int count = 0; printf(“Enter a string: “); …

C Example for Beginners: C Program to Find Largest Number Using Dynamic Memory Allocation

Hits: 162 (C programming Example for Beginners) C Program to Find Largest Number Using Dynamic Memory Allocation In this example, you will learn to find the largest number entered by the user in a dynamically allocated memory. Find the Largest Element in a Dynamically Allocated Memory #include <stdio.h> #include <stdlib.h> int main(){ int num; float …

C Example for Beginners: C Program to Multiply two Matrices by Passing Matrix to a Function

Hits: 22 (C programming Example for Beginners) C Program to Multiply two Matrices by Passing Matrix to a Function In this example, you’ll learn to multiply two matrices and display it using user defined function. This program asks the user to enter the size of the matrix (rows and column). Then, it asks the user …

C Example for Beginners: C Program to Multiply Two Matrices Using Multi-dimensional Arrays

Hits: 49 (C programming Example for Beginners) C Program to Multiply Two Matrices Using Multi-dimensional Arrays In this example, you will learn to multiply two matrices and display it using user-defined functions. This program asks the user to enter the size (rows and columns) of two matrices. To multiply two matrices, the number of columns of …

C Example for Beginners: C Program to Add Two Matrices Using Multi-dimensional Arrays

Hits: 66 (C programming Example for Beginners) C Program to Add Two Matrices Using Multi-dimensional Arrays In this example, you will learn to add two matrices in C programming using two-dimensional arrays. Program to Add Two Matrices #include <stdio.h> int main(){ int r, c, a[100][100], b[100][100], sum[100][100], i, j; printf(“Enter the number of rows (between …

C Example for Beginners: C Program to Calculate Standard Deviation

Hits: 89 (C programming Example for Beginners) C Program to Calculate Standard Deviation In this example, you will learn to calculate the standard deviation of 10 numbers using arrays. This program calculates the standard deviation of an individual series using arrays. Visit this page to learn about Standard Deviation. To calculate the standard deviation, we have …