Loading...
Loading...
00:00:00

Rules for writing c program

What Is Syntax?

Syntax in C language refers to the set of rules that define the structure and composition of valid C language programs. It specifies how keywords, operators, variables, and other elements should be arranged in a program to ensure that it is properly understood by the compiler and can be executed. Adhering to the correct syntax is important in order for the program to compile and run without errors.

In programming language syntax is predefined rule for writing code. Syntax means How to declare variables, uses of datatype , creating function , and writing the source code and where to use semicolon ,how to write statements in C programs. For example, In c Language every terminating statement ends with semicolon ; this is the rule you have to follow.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    printf("Hello World");  //valid syntax
    printf("Hello World")  //Invalid syntax
    return 0;
}

What is Keywords ?

Keywords in C language are reserved words that have a predefined meaning and cannot be used for other purposes, such as naming variables or functions. Examples of C keywords include "int", "float", "if", "else", "for", "while", "do", "switch", "case", "return", and many others. These keywords are an essential part of the C language and are used to define program structure, data types, and control flow. It is important to avoid using keywords as variable names or identifiers in order to prevent syntax errors and ensure proper functioning of the program.

There are 32 major keywords reverse by C language. We cannot use keywords as a variables name, functions name etc. Here is the some example keywords -

auto break case char
const continue default do
double else enum extern
float for goto if
int long register return
short signed sizeof static
struct switch typedef union
unsigned void volatile while