Major parts of a C program with proper example, 52D Batch


/*
        Author: Alamgir Hossain
        Date: 5/10/2020
        Purpose: to knowing major parts of a c program

*/// 1. Documentation part/documentation section
#include<stdio.h>//2. Linking part/Section
//#define x 50 //3. Definition Section
#define square(n) n * n
#define summation(num1, num2) num1 + num2//Macro
int p = 50;//4. Global Declaration Section/Part
char ch = 'z';
int multiply(int num1, int num2)//5. sub-program section
{
        int res = num1 * num2;
        return res;
}
void prime(){
        printf("Welcome to Prime University\n");
}
int main()//6. Main program section/part
{
        int x, y, r;
        x = 100;
        y = 200;
        printf("%d\n", x);
        prime();
        r = square(5);//Macro Calling
//        printf("%d\n", res);
        printf("%d\n", p);
        return 0;
}

No comments:

Post a Comment