C Programming Example

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

Hits: 25 (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: 294 (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: 152 (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: 39 (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: 181 (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: 48 (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: 415 (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 …