(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 code. In …
(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 pointer to …
(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]; int main(){ …
(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; } complex; …
(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; float marks; …
(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 manually. Concatenate …
(C programming Example for Beginners) C Program to Find the Length of a String In this example, you will learn to find the length of a string manually without using the strlen() function. As you know, the best way to find the length of a string is by using the strlen() function. However, in this example, we …
(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: “); fgets(line, sizeof(line), …
(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: “); fgets(str, sizeof(str), …
(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 *data; printf(“Enter …
(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 to enter …
(C programming Example for Beginners) C Program to Find Transpose of a Matrix In this example, you will learn to find the transpose of a matrix in C programming. The transpose of a matrix is a new matrix that is obtained by exchanging the rows and columns. In this program, the user is asked to …