0% found this document useful (0 votes)
14 views1 page

C Programming Basics for Beginners

This tutorial introduces the basics of C programming, covering its structure, variables, data types, input/output, conditional statements, loops, and functions. It emphasizes the importance of C's performance and its influence on modern programming languages. The tutorial encourages practice through writing small programs to reinforce understanding.

Uploaded by

mdmaraz604
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)
14 views1 page

C Programming Basics for Beginners

This tutorial introduces the basics of C programming, covering its structure, variables, data types, input/output, conditional statements, loops, and functions. It emphasizes the importance of C's performance and its influence on modern programming languages. The tutorial encourages practice through writing small programs to reinforce understanding.

Uploaded by

mdmaraz604
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 Basics Tutorial

C is one of the most powerful and widely used programming languages. It is known for its
performance, simplicity, and influence on many modern languages like C++, Java, and Python. This
tutorial covers the basic concepts you need to start coding in C.

1. Structure of a C Program
Every C program follows a standard structure:
#include int main() { printf("Hello, World!"); return 0; } Explanation:
• #include — includes the Standard Input/Output library.
• int main() — main function where execution starts.
• printf() — prints output to the screen.
• return 0; — ends the program successfully.

2. Variables and Data Types


Variables are used to store data. You must declare the type before using them.
Example:
int age = 20; float height = 5.9; char grade = 'A'; Common Data Types:
• int – integers (e.g., 10, -5)
• float – decimal numbers (e.g., 3.14)
• char – single characters (e.g., 'A')
• double – large floating numbers

3. Input and Output


To take input from the user, use scanf().
Example:
int num; printf("Enter a number: "); scanf("%d", #); printf("You entered: %d", num);

4. Conditional Statements
C uses if, else if, and else for decision making.
Example:
int x = 10; if (x > 0) { printf("Positive"); } else { printf("Non-positive"); }

5. Loops
Loops help repeat actions.
For loop example:
for(int i = 1; i <= 5; i++) { printf("%d\n", i); } While loop example:
int i = 1; while(i <= 5) { printf("%d\n", i); i++; }

6. Functions
Functions are blocks of code designed to perform specific tasks.
Example:
#include void greet() { printf("Hello from a function!"); } int main() { greet(); return 0; }

Conclusion
You’ve now learned the basics of C programming — structure, variables, input/output, conditions,
loops, and functions. The next step is to practice by writing small programs to strengthen your
understanding.

You might also like