Start your programming journey with one of the most powerful and foundational languages — C. This comprehensive course is designed for absolute beginners as well as intermediate learners who want to build a solid understanding of programming using the C language. Whether you're preparing for college-level programming, cracking technical interviews, or planning to explore systems or embedded development, this course covers everything step-by-step. Through hands-on examples, real-world practice problems, and structured explanations, you’ll learn how to write clean and efficient C code — from your first printf() to advanced data structures and memory management.
Input and output (I/O) are essential to make your C programs interactive. Without I/O functions, a program would only process fixed data and produce output without user involvement. In C, we primarily use printf() to display information and scanf() to take input from the user.
printf()?
printf() is used to send formatted output to the screen. It's part of the standard I/O library in C (stdio.h).
#include <stdio.h>
int main() {
printf("Welcome to UdaanPath!\n");
return 0;
}
printf():%d – for integers (e.g., int age = 20;)%f – for floating-point values (e.g., float pi = 3.14;)%c – for single characters (e.g., char grade = 'A';)%s – for strings (e.g., char name[] = "Rahul";)%.2f – to display float with 2 decimal places\n – New line\t – Tab space\\ – Backslash\" – Double quotescanf()?
scanf() is used to take input from the user. It scans the input and stores it in variables via pointers (using & symbol).
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d years old.\n", age);
return 0;
}
scanf() needs the address of the variable (& symbol).scanf() reads inputs.int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
printf("Sum = %d\n", a + b);
Use scanf("%s", str) to read a string (till whitespace). For full sentence input, use fgets().
char name[50];
printf("Enter your name: ");
scanf("%s", name);
printf("Hello %s, welcome to UdaanPath!\n", name);
char line[100];
printf("Enter a sentence: ");
fgets(line, sizeof(line), stdin);
printf("You entered: %s", line);
| Function | Purpose | Common Use |
|---|---|---|
printf() |
Displays output | Showing messages, variables, results |
scanf() |
Takes user input | Reading numbers, characters, strings |
fgets() |
Reads full string lines | Reading names/sentences with spaces |
fgets() and displays a greeting message.printf() is used for output. It supports format specifiers to print variables.scanf() is used for input. Use & before variables to store input values.fgets() for safety and completeness.In the next chapter, we’ll dive into Operators and Expressions — the foundation of decision-making and calculations in C.