Chapter 1 source code

 Source code for the chapter 1

Program1: Main.c

// Our first program
#include <stdio.h>

int main(){
    printf("Hello World\n");
    return 0;
}

 Program2: Variables.c

#include <stdio.h>

int main(){
    int a = 34;
    int b = 2;
    printf("The sum is %d\n", a+b);
    return 0;
}

Program3: Data types.c

#include <stdio.h>

int main(){
    int i = 5; // It stores an integer.
    float f = 4.5; // It stores a decimal number.
    char c = 'A'; // It stores character.
    printf("%d", i); // format specifier for Integer
    printf("%f", f); // Format specifier for float
    printf("%c", c); // format specifier for charachter
    return 0;
}

Program4: Challenge.c

#include <stdio.h>

int main(){
    int a = 2;
    int b = 5;
    printf("The sum of 2 and 5 is %d", a+b);
    return 0;
}

Program5: Scanf.c

#include <stdio.h>

int main(){
    int a;
    printf("Enter the value of a:  \n");
    scanf("%d", &a); /* & opreator to store it's value or address.
     What is address you will learn about this in pointers but for this
     time you should remember that it is
     the syntax of storing the value of variable it is important to write &*/
    printf("%d", a);
    return 0;
}

Program6: Comments.c

// This is a single line comment
/*This                                      is                          
a                   multiline comment       */

Txt file: Syntax.txt


This source code is ready for you now you can practice this until I launch the practice set after I will give you the solutions. In the source code.

Comments

Popular posts from this blog

Chapter 1 practice set

C language chapter 1