Posts

C Programming Tutorials – Complete Guide from Basics to Advanced

Welcome to C Tutorials MP , a learning resource for students who want to learn C programming step by step. Explore the topics below, read the explanations, practise programs, and strengthen your programming fundamentals. How to use this guide: Start with Section 1 and continue in order. Click any topic to open its dedicated tutorial. We will keep this index updated as more lessons are added. 1. Introduction to C Programming Introduction to C Programming History and Features of C Applications and Advantages of C Structure of a C Program Writing and Executing Your First C Program Compiler, Interpreter and IDE 2. Tokens, Variables and Data Types Tokens in C Keywords and Identifiers Variables and Constants Data Types in C Declaration and Initialization of Variables Type Conversion and Type Casting 3. Input, Output and Operators printf() and scanf() Functions Operators in C Arithmetic and Relational Operators Logical and Assignment Operators Increment and Decrement Operators Operator Prece...

Array Data Structure in C, Types of Array 1D, 2D and nD (Multidimensional Array) and Need of Array (C में Array Data Structure, Array के प्रकार (1D, 2D और nD) तथा Array की आवश्यकता)

An Array is a collection of elements of the same data type stored in contiguous memory locations. All elements are accessed using a common array name and an index (subscript). The index of an array starts from 0 and ends at size - 1 . The address of the first element of an array is called the Base Address of the array. In C language, an array is an important data structure used to store and process multiple values using a single name. Array एक ही Data Type के अनेक Elements का समूह होता है। इसके सभी Elements कंप्यूटर की Memory में क्रमागत (Contiguous) स्थानों पर संग्रहीत होते हैं। Array के सभी Elements को एक ही नाम से पहचाना जाता है तथा प्रत्येक Element का अपना Index होता है। Array का Index हमेशा 0 से शुरू होता है और अंतिम Index size - 1 होता है। Array के पहले Element का Address उसका Base Address कहलाता है। C भाषा में Array का उपयोग एक ही नाम के अंतर्गत अनेक Values को संग्रहीत करने और उन पर आसानी से कार्य करने के लिए किया जाता है। Example of an Array Consider an integer array cont...

C Program to Find Multiplication of Two Matrices (दो Matrices का गुणा ज्ञात करने का C प्रोग्राम)

Matrix multiplication is the process of multiplying rows of the first matrix by columns of the second matrix. The number of columns in the first matrix must be equal to the number of rows in the second matrix. Matrix Multiplication वह प्रक्रिया है जिसमें पहली Matrix की Rows और दूसरी Matrix के Columns के तत्वों का गुणा करके उनका योग निकाला जाता है। दो Matrices का गुणा तभी संभव है जब पहली Matrix के Columns की संख्या दूसरी Matrix की Rows की संख्या के बराबर हो। In this program, Matrix A has 3 rows and 2 columns (3×2), while Matrix B has 2 rows and 3 columns (2×3). Therefore, the resultant matrix will have 3 rows and 3 columns (3×3). इस प्रोग्राम में Matrix A का आकार 3×2 और Matrix B का आकार 2×3 है। इसलिए गुणा करने के बाद प्राप्त होने वाली Resultant Matrix का आकार 3×3 होगा। C Program #include <stdio.h> #define R1 3 #define C1 2 #define R2 2 #define C2 3 int main() { int a[R1][C1], b[R2][C2]; int m[R1][C2]; int i, j, k; printf("Enter elements of Matrix A:\n"); ...

C Program to Find Sum of Diagonal Elements of a Matrix (Matrix के Diagonal Elements का योग ज्ञात करने का C प्रोग्राम)

The diagonal elements of a square matrix are the elements whose row and column indices are equal. In this program, we calculate the sum of the main diagonal elements of a 3×3 matrix. Square Matrix के मुख्य विकर्ण (Main Diagonal) के वे तत्व होते हैं जिनके Row और Column Index समान होते हैं। इस प्रोग्राम में हम 3×3 Matrix के मुख्य विकर्ण के तत्वों का योग ज्ञात करेंगे। C Program #include <stdio.h> #define R 3 #define C 3 int main() { int a[R][C], sum = 0; int i, j; printf("Enter elements of a Matrix:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter A[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } /* Sum of main diagonal elements */ for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { if (i == j) { sum = sum + a[i][j]; } } } printf("\nSum of diagona...

C Program to Find Transpose of a Matrix (Matrix का Transpose ज्ञात करने का C प्रोग्राम)

The transpose of a matrix is obtained by interchanging its rows and columns. In the transpose matrix, rows become columns and columns become rows. किसी Matrix की Rows को Columns में और Columns को Rows में बदलने पर उसका Transpose प्राप्त होता है। इस प्रोग्राम में हम एक 2×2 Matrix का Transpose ज्ञात करेंगे। C Program #include <stdio.h> #define R 2 #define C 2 int main() { int a[R][C], b[C][R]; int i, j; printf("Enter elements of Matrix A:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter A[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } printf("\nMatrix A is:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("%d\t", a[i][j]); } printf("\n"); } /* Finding transpose of Matrix A */ for (i = 0; i < R; i++) { for (j = 0; j ...

C Program to Calculate Subtraction of Two Matrices (दो Matrices का घटाव ज्ञात करने का C प्रोग्राम)

Matrix subtraction is the process of subtracting the corresponding elements of one matrix from another matrix having the same number of rows and columns. Matrix Subtraction वह प्रक्रिया है जिसमें समान Rows और Columns वाली दो Matrices के संगत तत्वों को घटाया जाता है। इस प्रोग्राम में हम दो 2×2 Matrices का घटाव ज्ञात करेंगे। C Program #include <stdio.h> #define R 2 #define C 2 int main() { int a[R][C], b[R][C], sub[R][C]; int i, j; printf("Enter elements of Matrix A:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter A[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } printf("\nEnter elements of Matrix B:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter B[%d][%d] = ", i, j); scanf("%d", &b[i][j]); } } /* Subtraction of two matr...

C Program to Calculate Addition of Two Matrices (दो Matrices का जोड़ ज्ञात करने का C प्रोग्राम)

Matrix addition is the process of adding the corresponding elements of two matrices having the same number of rows and columns. Matrix Addition वह प्रक्रिया है जिसमें समान Rows और Columns वाली दो Matrices के संगत तत्वों को जोड़ा जाता है। इस प्रोग्राम में हम दो 2×2 Matrices का जोड़ ज्ञात करेंगे। C Program #include <stdio.h> #define R 2 #define C 2 int main() { int a[R][C], b[R][C], add[R][C]; int i, j; printf("Enter elements of Matrix A:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter A[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } printf("\nEnter elements of Matrix B:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter B[%d][%d] = ", i, j); scanf("%d", &b[i][j]); } } /* Addition of two matrices */ for (i = 0; i < R...

C Program for Sorting a 1D Array Using Bubble Sort (Bubble Sort की सहायता से 1D Array को Sort करने का C प्रोग्राम)

Sorting is the process of arranging array elements in a particular order, such as ascending or descending order. In this program, we use the Bubble Sort technique to arrange array elements in ascending order. Sorting वह प्रक्रिया है जिसमें Array के तत्वों को किसी निश्चित क्रम में व्यवस्थित किया जाता है, जैसे छोटे से बड़े या बड़े से छोटे क्रम में। इस प्रोग्राम में Bubble Sort तकनीक का उपयोग करके Array के तत्वों को छोटे से बड़े क्रम में व्यवस्थित किया जाएगा। C Program #include <stdio.h> #define N 10 int main() { int list[N], i, j, temp; printf("Enter %d elements:\n", N); for (i = 0; i < N; i++) { printf("Enter element %d: ", i + 1); scanf("%d", &list[i]); } printf("\nBubble Sort\n"); printf("Before Sorting: "); for (i = 0; i < N; i++) { printf("%d ", list[i]); } for (i = 0; i < N - 1; i++) { for (j = 0; j < N - i - 1; j++) ...