Last Minute C Programming Syntax Basics Tutorial - Part 1

C Programming Syntax Basics

Letus learn C Programming Syntax Basics in this multipart tutorial which are useful for students in the last minute before exam. C Programming Language was invented by Dennis Ritchie in Bell Laboratories. Now Nokia owns Bell Laboratories and experiments are still going on.

C Programming Syntax Basics Part 1

We shall learn about basic structure of a C Program and predefined Keywords in this C Programming Syntax Basics Tutorial Part 1. You can set up a Turbo C Compiler on your Windows Machine easily.

Online Tests on C Basics

1 C Programming Basics 1
2 C Programming Basics 2

Structure of a C Program

Every C program contains a function or method called main(). All functions end with Round Brackets or Paranthesis ( ). Inside Paratheses, arguments can be received or passed. Code of a Function is surrounded by Curly Brackets or Braces { }.

#include <stdio.h>
void main()
{
  /*This is a multi-line comment.
     It is not compiled or checked for Syntax*/
  printf("Hello C..");
}

Output


Hello C..

Observations

  1. VOID is a return type. VOID means nothing is being returned.
  2. main() { } is a compulsory function in any C Program.
  3. void and main should be typed in lowercase completely.
  4. / symbol is called Forward Slash or simply Slash.
  5. * symbol is called STAR.
  6. /* */ is a multiline comment. Comments are useful for analysing code logic flow in very big projects. Comments make others easily understand your program or project.
  7. printf() is a function which is passing one argument "Helllo C".
  8. "Hello C" is a string literal here.
  9. Code statements or lines end with Semicolon ;
  10. Putting a return type before a function name is not mandatory in a C Compiler. If you use a C++ Compiler to compile c programs, you must specify a return type.
  11. #include includes an already written header file stdio.h which contains code for printf function. Without predefined functions, life becomes difficult to write everything every time on our own. Also the code without including files becomes clumsy to maintain and understand.

Keywords in C Language

There are a total of 32 keywords in C Language which can not be used for the names of variables and functions. Find the C Programming Keyword list below. Students need to remember these keywords just like that to attempt questions asked in their exams.

Keyword Meaning
auto  Defines local life time for a variable
break  Breaks a current loop in general
case  Defines branch control point
char  Basic data type, character literal
const  Defines a Constant, unmodified variable
continue  control goes to the loop beginning
default  control point used in switch construct in general
do  do while loop
double  Floating point data type bigger than float type
else  Usually followed by if construct. If conditon fails, branch to else block
enum  Used to define a  group of int constants like array
extern  Used to define a variable or function with type and the definition may exist some where 
float  Floating point data type
for  For Loop
goto  Transfers execution control to defined Label
if  A conditional statement
int  Basic integer data type
long  Integer data type bigger than int
register  Tells to store the variable in RAM register
return ends execution immediately
short  Type Modifier
signed  Type Modifier
sizeof used to get the size of a variable. Eg. sizeof(integerType)
static used to create a variable with broad scope
struct  Used to define a custom data type kind of thing
switch  switch branch control
typedef  used to create new type
union used in grouping of variables of same type
unsigned Modifiere used to increase positive max value
void  empty data type or return type
volatile Used to create a variable with a value changed by any external process
while while loop with a condition

C 32 Keywords Infographic

c 32 keywords infographic examtray

 

We shall meet in our next Lesson on C Data Types. Data Type is simply the type of data your program deals with.