0% found this document useful (0 votes)
8 views7 pages

C Programming Tutorial Guide

This document is a tutorial on C programming, covering essential topics such as writing your first program, using variables, format specifiers, arithmetic operators, and conditional statements. Each chapter includes code examples and explanations to help beginners understand the concepts. The tutorial is structured to guide users through the basics of C programming step by step.

Uploaded by

arijit1seal09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

C Programming Tutorial Guide

This document is a tutorial on C programming, covering essential topics such as writing your first program, using variables, format specifiers, arithmetic operators, and conditional statements. Each chapter includes code examples and explanations to help beginners understand the concepts. The tutorial is structured to guide users through the basics of C programming step by step.

Uploaded by

arijit1seal09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C PROGRAMMING

TUTORIAL
Table of Contents
Chapter 1: Your First C Program .......... 00:09:53
Chapter 2: Variables .......... 00:15:04
Chapter 3: Format Specifiers .......... 00:35:06
Chapter 4: Arithmetic Operators .......... 00:44:15
Chapter 5: If Statements .......... 01:44:28
Chapter 1: Your First C Program (00:09:53)
Let's begin our journey with the classic "Hello World" program. This introduces the structure of a
basic C program.

#include <stdio.h> int main() { printf("Hello, World!"); return 0; } Explanation:


- #include <stdio.h> imports the Standard I/O library.
- int main() is the program entry point.
- printf() prints output to the console.
- return 0; signals successful program termination.
Chapter 2: Variables (00:15:04)
Variables store information that can change while your program runs.

#include <stdio.h> int main() { int age = 21; float gpa = 3.8; char grade = 'A'; printf("Age: %d\n",
age); printf("GPA: %.2f\n", gpa); printf("Grade: %c\n", grade); return 0; } Explanation:
- int: whole numbers
- float: decimal numbers
- char: single characters
Tip: Always initialize variables before using them.
Chapter 3: Format Specifiers (00:35:06)
Format specifiers control how data appears when printed.

| Specifier | Type | Example | |------------|------|----------| | %d | int | 42 | | %f | float | 3.14159 | | %.2f


| float (2 decimals) | 3.14 | | %c | char | A | | %s | string | Hello |

#include <stdio.h> int main() { int score = 95; float pi = 3.14159; char initial = 'B'; char name[] =
"Bro Code"; printf("Score: %d\n", score); printf("Pi: %.2f\n", pi); printf("Initial: %c\n", initial);
printf("Name: %s\n", name); return 0; }
Chapter 4: Arithmetic Operators (00:44:15)
C supports arithmetic operations.

| Operator | Meaning | Example | Result | |-----------|----------|----------|--------| | + | Addition | 5 + 3 |


8 | | - | Subtraction | 5 - 3 | 2 | | * | Multiplication | 5 * 3 | 15 | | / | Division | 5 / 2 | 2 | | % | Modulus |
5%2|1|

#include <stdio.h> int main() { int a = 10, b = 3; printf("Sum: %d\n", a + b); printf("Difference:
%d\n", a - b); printf("Product: %d\n", a * b); printf("Quotient: %d\n", a / b); printf("Remainder:
%d\n", a % b); return 0; }
Chapter 5: If Statements (01:44:28)
Conditional statements allow decision-making in programs.

#include <stdio.h> int main() { int age; printf("Enter your age: "); scanf("%d", &age;); if (age >=
18) { printf("You are an adult.\n"); } else { printf("You are a minor.\n"); } return 0; } Explanation:
- if(condition) checks truth.
- else runs if false.
- Relational operators: >, <, >=, <=, ==, !=.

You might also like