0% found this document useful (0 votes)
3 views30 pages

C Programming 30 Pages Guide

This document is a beginner's guide to C programming, covering fundamental concepts such as variables, data types, input/output, operators, control structures, functions, arrays, pointers, and file handling. It also includes examples of code snippets for each topic and concludes with suggestions for practice and project building. The guide serves as a comprehensive introduction for those new to C programming.

Uploaded by

jayloungani7
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)
3 views30 pages

C Programming 30 Pages Guide

This document is a beginner's guide to C programming, covering fundamental concepts such as variables, data types, input/output, operators, control structures, functions, arrays, pointers, and file handling. It also includes examples of code snippets for each topic and concludes with suggestions for practice and project building. The guide serves as a comprehensive introduction for those new to C programming.

Uploaded by

jayloungani7
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 Complete Beginner Guide (30

Pages)

Introduction to C

C is a powerful low-level programming language used for system programming, embedded


systems, and performance-critical applications.
#include <stdio.h>
int main(){
printf("Hello World");
return 0;
}
Variables & Data Types

Variables store data. Common types include int, float, char.


int a=10;
float b=5.5;
char c='A';
Input and Output

Use printf for output and scanf for input.


int x;
scanf("%d",&x);
printf("%d",x);
Operators

Operators perform operations like +, -, *, /.


int sum = 5 + 3;
If-Else Statements

Conditional execution.
if(x>0){ printf("Positive"); } else { printf("Negative"); }
Switch Case

Alternative to if-else.
switch(x){ case 1: printf("One"); break; }
Loops - For

Used for repeating tasks.


for(int i=0;i<5;i++){ printf("%d",i); }
Loops - While

Repeats while condition is true.


while(x>0){ x--; }
Loops - Do While

Executes at least once.


do{ x--; }while(x>0);
Functions

Functions reuse code.


int add(int a,int b){ return a+b; }
Arrays

Store multiple values.


int arr[5]={1,2,3,4,5};
Strings

Character arrays.
char str[]="Hello";
Pointers

Store memory addresses.


int a=10;
int *p=&a;
Pointer Arithmetic

Operations on pointers.
p++;
Dynamic Memory

Allocate memory using malloc.


int *p = malloc(sizeof(int));
Structures

Group variables.
struct student{ int id; };
Unions

Share memory.
union data{ int i; float f; };
File Handling

Read/write files.
FILE *f = fopen("[Link]","r");
Command Line Args

Arguments from terminal.


int main(int argc, char *argv[]){}
Recursion

Function calling itself.


int fact(int n){ if(n==0) return 1; return n*fact(n-1);}
Preprocessor

Macros and includes.


#define PI 3.14
Bitwise Operators

Operate on bits.
int x = 5 & 3;
Enums

Named constants.
enum day{MON,TUE};
Typedef

Rename types.
typedef int num;
Storage Classes

auto, static, extern.


static int x;
Error Handling

Basic checks.
if(ptr==NULL){ printf("Error"); }
Makefiles

Build automation.
gcc main.c -o app
Debugging

Using printf or gdb.


printf("Debug");
Mini Project

Simple calculator.
int main(){ int a,b; scanf("%d%d",&a,&b); printf("%d",a+b);}
Next Steps

Practice and build projects.

You might also like