Uncategorized

Uncategorized

What is C Programming? Introduction to C Language

What is C Programming C is a general-purpose programming language. It was developed by Dennis Ritchie at Bell Laboratories in the early 1970s. C became popular because it is fast, flexible and gives programmers good control over computer memory. How C developed — in simple words Why should we learn C? Features of C A feature is a useful quality of a programming language. C has many features that make it important even today. How To install C To run a C program, you need a C compiler. GCC is one of the most commonly used C compilers. Method 1: GCC on Windows 5. If a GCC version appears, the compiler is ready. Create and run your first file Save the file as hello.c. Then compile it: Run it. On Windows, the executable is normally hello.exe. On Linux/macOS, you can usually run: First C Program Let us understand the most common beginner program. Do not just memorize it—understand what each line does. Line-by-line explanation #include <stdio.h> → Adds declarations for standard input/output functions such as printf(). int main() → Defines the main function. Program execution starts from main(). { } → Marks the beginning and end of the function body. printf(“Hello, World!”); → Displays the message on the screen. return 0; → Ends main and commonly indicates successful completion. Compilation Process in C The computer cannot directly execute normal C source code. The source code goes through several stages before an executable program is produced. 1. Source Code → The programmer writes a .c file. 2. Preprocessing → #include, #define and other preprocessor directives are handled. 3. Compilation → The C source is translated and checked for C language rules. 4. Assembly → Assembly instructions are converted into object/machine code. 5. Linking → Object code is combined with required library code to create an executable. 6. Execution → The operating system loads and runs the executable. Example GCC command printf() and scanf() These two functions are used in many beginner C programs. printf() is mainly used to display output, while scanf() is commonly used to read formatted input. printf() — display output Important format specifiers Specifier Meaning Example %d integer printf(“%d”, age); %f floating-point value printf(“%.2f”, price); %c single character printf(“%c”, grade); %s string printf(“%s”, name); %lf double with scanf() scanf(“%lf”, &value); scanf() — take input The & before a normal variable gives its address. scanf() uses that address to store the input value. Complete program OUTPUT Enter age: 21 Enter marks: 87.5 Enter grade: A Age = 21 Marks = 87.50 Grade = A

Scroll to Top