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...

Tic-Tac-Toe game program in C (C भाषा में Tic-Tac-Toe गेम प्रोग्राम)

Tic-Tac-Toe is a simple two-player game played on a 3×3 grid. Players take turns marking the grid with X and O. The first player to get three marks in a row, column, or diagonal wins. Tic-Tac-Toe दो खिलाड़ियों का एक सरल गेम है, जो 3×3 Grid पर खेला जाता है। खिलाड़ी बारी-बारी से X और O लगाते हैं। जो खिलाड़ी एक ही Row, Column या Diagonal में तीन Marks बना लेता है, वह गेम जीत जाता है। C Program #include <stdio.h> int main() { char data[9] = {'1','2','3','4','5','6','7','8','9'}; int index, count = 0, winner = 0; int player = 1; char sign; while (count < 9) { /* Display the board */ printf("\n"); printf(" %c | %c | %c \n", data[0], data[1], data[2]); printf("---+---+---\n"); printf(" %c | %c | %c \n", data[3], data[4], data[5]); printf("---+---+---\n"); printf(" %c | %c | %c \...

Simple Fan Program in C Using Graphics (C Graphics की सहायता से Simple Fan प्रोग्राम)

This C graphics program creates a simple animated fan. The fan blades rotate continuously using graphics functions and mathematical calculations. यह C Graphics प्रोग्राम एक साधारण घूमता हुआ पंखा बनाता है। Graphics Functions और Mathematical Calculations की सहायता से पंखे की Blades लगातार घूमती रहती हैं। C Program #include <stdio.h> #include <graphics.h> #include <conio.h> #include <math.h> #include <dos.h> #define PI 3.14159265 void fan(int p); int main() { int gd = DETECT, gm = 0; initgraph(&gd, &gm, ""); fan(100); closegraph(); return 0; } void fan(int p) { int xf = 250, yf = 250; int i; float angle; int x1, y1, x2, y2; while (!kbhit()) { cleardevice(); /* Fan center */ circle(xf, yf, 25); circle(xf, yf, 3); /* Fan stand */ line(xf, yf + 25, xf, yf + 100); line(xf - 40, yf + 100, xf + 40, yf + 100); /* Rotating blades */ fo...

C Program to Reverse Elements of a 1D Array (1D Array के Elements को Reverse करने का C प्रोग्राम)

Reversing an array means changing the order of its elements so that the first element becomes the last and the last element becomes the first. Array को Reverse करने का अर्थ है उसके Elements का क्रम उलट देना। इसमें पहला Element अंतिम स्थान पर और अंतिम Element पहले स्थान पर आ जाता है। C Program #include <stdio.h> #define N 10 int main() { int list[N], i, j, temp; printf("Enter elements of List\n"); for (i = 0; i < N; i++) { printf("%d element = ", i + 1); scanf("%d", &list[i]); } printf("List Array is:\n"); for (i = 0; i < N; i++) { printf("%d ", list[i]); } /* Reverse the array */ for (i = 0, j = N - 1; i < j; i++, j--) { temp = list[i]; list[i] = list[j]; list[j] = temp; } printf("\nReversal of List Array is:\n"); for (i = 0; i < N; i++) { printf("%d ", list[i]); }...

Bouncing Ball Program in C Using Graphics (C Graphics में Bouncing Ball प्रोग्राम)

A bouncing ball is a simple computer graphics animation in which a ball moves horizontally and bounces up and down. The animation repeats continuously using a loop. Bouncing Ball एक सरल Computer Graphics Animation है, जिसमें एक गेंद स्क्रीन पर आगे बढ़ते हुए ऊपर-नीचे उछलती है। Loop की सहायता से यह Animation लगातार Repeat होता रहता है। C Program #include <stdio.h> #include <conio.h> #include <graphics.h> #include <dos.h> int main() { int gd = DETECT, gm = 0; int x, y, direction; initgraph(&gd, &gm, ""); setcolor(RED); setfillstyle(SOLID_FILL, RED); while (!kbhit()) { x = 40; y = 100; direction = 1; while (x < 602) { cleardevice(); circle(x, y, 30); floodfill(x, y, RED); delay(40); x += 5; y += direction * 10; if (y >= 400) { y = 400; direction = -1...

C Program to Calculate Sum and Average of 1D Array. 1D Array के Elements का Sum और Average निकालने का C प्रोग्राम

A one-dimensional (1D) array stores multiple elements of the same data type. We can calculate the sum of all elements and their average using a loop. One-dimensional (1D) Array में एक ही Data Type के कई Elements Store किए जाते हैं। Loop की सहायता से सभी Elements का Sum और Average निकाला जा सकता है। Formula (सूत्र) Sum = Addition of all array elements (सभी Array Elements का जोड़) Average = Sum / Total number of elements (Sum / कुल Elements की संख्या) C Program #include <stdio.h> #define N 5 int main() { int list[N], i, sum = 0; float avg; printf("Enter Elements of List Array\n"); for (i = 0; i < N; i++) { printf("Enter %d Element = ", i + 1); scanf("%d", &list[i]); sum = sum + list[i]; } avg = (float)sum / N; printf("Sum = %d and Average = %.2f\n", sum, avg); return 0; } Sample Output (आउटपुट) Enter Elements of List Array Enter 1 Element = 10 Enter 2 Element = 20 Enter 3 Elem...

C Program for Linear or Sequential Search लीनियर या सेक्वेंशिअल सर्च

Linear Search is a simple searching technique used to find an element in an array. It checks each element one by one until the required item is found or the array ends. Linear Search एक सरल Searching Technique है, जिसका उपयोग Array में किसी Element को खोजने के लिए किया जाता है। इसमें प्रत्येक Element को एक-एक करके Check किया जाता है, जब तक Element मिल न जाए या Array समाप्त न हो जाए। C Program #include <stdio.h> #define N 5 int main() { int list[N], i, item; printf("Enter 5 Array Elements:\n"); for (i = 0; i < N; i++) { scanf("%d", &list[i]); } printf("Enter an item to search: "); scanf("%d", &item); for (i = 0; i < N; i++) { if (item == list[i]) { printf("Searching is Successful\n"); printf("%d is found at Index %d and Position %d\n", item, i, i + 1); return 0; } } printf...

Rainbow Program in C Language (C में इंद्रधनुष बनाने का प्रोग्राम)

Image
The Rainbow program in C uses graphics functions to draw a beautiful rainbow on the screen. It demonstrates the use of arcs, colors, loops, and graphics functions in C programming. C भाषा में Rainbow प्रोग्राम Graphics Functions की सहायता से स्क्रीन पर इंद्रधनुष बनाता है। यह प्रोग्राम Arcs, Colors, Loops तथा Graphics Functions के उपयोग को समझने में मदद करता है। C Program #include <stdio.h> #include <graphics.h> #include <conio.h> #include <dos.h> void rainbow() { int gd = DETECT, gm; int x, y, i; int colors[] = { RED, LIGHTRED, YELLOW, GREEN, LIGHTCYAN, BLUE, MAGENTA }; initgraph(&gd, &gm, "C:\\TURBOC3\\BGI"); x = getmaxx() / 2; y = getmaxy() / 2; for (i = 0; i < 7; i++) { setcolor(colors[i]); arc(x, y, 0, 180, 60 + i * 20); delay(300); } getch(); closegraph(); } int main() { rainbow(); return 0; } Output The program displays seven colored semicir...