Skip to content

shihablabs/programming-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Programming-C

Programming C: Solidify your skills in the C programming language. Explore concise code examples, grasp key concepts, and build a strong foundation. Start your C programming journey now!

Basic C Programming: Building a Strong Foundation

Introduction:

Welcome to the world of Basic C Programming! This repository is designed to provide you with a solid foundation in the fundamentals of C programming. Whether you are a beginner taking your first steps in the programming world or an experienced developer looking to enhance your skills, this repository will guide you through the essential concepts of C programming.

Main Things in Programming (C)

Variables:

  • Variables are used to store data in a program. They have a specific data type (such as int, float, char) and a name that you can assign. You can assign values to variables and perform operations on them.
In C, there are different types of variables (defined with different keywords), for example:

int - stores integers (whole numbers), without decimals, such as 123 or -123
float - stores floating point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
  • Declaring (Creating) Variables

To create a variable, specify the type and assign it a value:

# Syntax
type variableName = value;
  • Format Specifiers: Format specifiers are used together with the printf() function to tell the compiler what type of data the variable is storing. It is basically a placeholder for the variable value.

    // Create variables
    int myNum = 15;            // Integer (whole number)
    float myFloatNum = 5.99;   // Floating point number
    char myLetter = 'D';       // Character
    
    // Print variables
    printf("%d\n", myNum);
    printf("%f\n", myFloatNum);
    printf("%c\n", myLetter);
    
    // Student data
    int studentID = 15;
    int studentAge = 23;
    float studentFee = 75.25;
    char studentGrade = 'B';
    
    // Print variables
    printf("Student id: %d\n", studentID);
    printf("Student age: %d\n", studentAge);
    printf("Student fee: %f\n", studentFee);
    printf("Student grade: %c", studentGrade);
    
    // Create a variable and assign the value 15 to it
    int myNum = 15;
    
    // Declare a variable without assigning it a value
    int myOtherNum;
    
    // Assign the value of myNum to myOtherNum
    myOtherNum = myNum;
    
    // myOtherNum now has 15 as a value
    printf("%d", myOtherNum);

Data Types:

  • C has various data types, including int (for integers), float (for floating-point numbers), char (for characters), and more. Each data type determines the range of values and the type of operations that can be performed on the variables.

Operators:

  • Operators are used to perform operations on variables or values. Examples include arithmetic operators (+, -, *, /), assignment operators (=), comparison operators (==, !=, >, <), and logical operators (&&, ||, !).

Control Structures:

  • Control structures allow you to control the flow of execution in a program. Common control structures in C include if-else statements, switch statements, and loops (such as for, while, and do-while loops).

Functions:

  • Functions are blocks of code that perform a specific task. They allow you to break down your program into smaller, reusable parts. Functions have a return type (void or a specific data type) and can accept input parameters.

Arrays:

  • Arrays allow you to store multiple values of the same data type in a contiguous memory block. Elements in an array are accessed using their indices.

Pointers:

  • Pointers store memory addresses. They allow you to directly manipulate memory, access variables indirectly, and allocate dynamic memory.

Input and Output:

  • C provides functions like scanf() and printf() for input and output operations. scanf() is used to read input from the user, and printf() is used to display output on the screen.

Libraries:

  • C provides standard libraries that contain pre-defined functions to perform various tasks. Examples include stdio.h for input/output operations, math.h for mathematical functions, and string.h for string manipulation.

Error Handling:

  • Error handling involves handling and managing errors or exceptional situations that may occur during program execution. This can be done using techniques like error codes, error messages, and exception handling mechanisms.

Merge Sorting Algorithm

Here is the slide

Here is the outpup

About

Programming C: Solidify your skills in the C programming language. Explore concise code examples, grasp key concepts, and build a strong foundation. Start your C programming journey now!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages