Syntax in C

Syntax in C

To know why syntax is important click here.
  • printf("...",arguments)

  • Output: ...
  • scanf("format specifiers",&variable)

  • Output: It will take value from user. 
  • if(condition)
  • {...}
    else
    {...}
    Output: We can use this when we need to check condition and thereby assign task. 

  • if(condition)
  • {...}
    else if(condition)
    {...}
    else
    {...}
    Output: We can use this when we need to check multiple condition and thereby assign task. 
  • for(initialization; condition; incrementation or decrementation)

  • Output: We can use this when we need to iterate any task.

  • while(condition)
  • {...}
    Output: We can use this when we need to iterate any task. 
  • do
  • {...}
    while(condition);
    Output: We can use this when we need to iterate any task.  
  • switch(variable)
  • {
    case 1: ...
    break;
    case 2: ...
    break;
    .
    .
    .
    default: ...
    break;
    }
    Output: We can use when we want to select a specific task out of several tasks.  
    Note:If we don't use break statement then all further statements will be executed till it encounters an break statement or default statement.
  • return_type function_name(parameters)
  • {...
    return_statement; }


No comments:

Post a Comment