Professional Documents
Culture Documents
Lec 02
Lec 02
Computer Programming
Basic Syntax
Comments, Input and Output
Comments
• Comments are often helpful for understanding the specific
functions of any part of a code.
• All comments are ignored by the compiler. As if they don’t
exist.
• A single line comment must start with “ // “ and ends with
the line.
• A multi line comment starts with “ /* “ and ends with “ */ “
A Code With Comments
#include <stdio.h>
int main( )
{
// This is a comment. Only use it when single line
/* This format is used for both single line
and multi line */
printf("Only this line will be executed"); // This is also a comment
/* Remember that no comment will be executed, they are ignored */
return 0;
}
Comments
Notice that the color of comments is changed from normal text, usually
the color is light.
Data Types
• So any line we can print using this function. But for printing a data
type we need some modification.
Printing Data Types
• For printing the data types we need to write specific text for each
type.
• %d is for int
• %c for char
• %f for float
• %lf for double (Double is nothing but long float)
• For creating a new line for output we need to put “ \n “ within printf.
Example
Example
Scanf function
• Don’t forget to use the ‘&’ sign before the data type name. It
is called “assign to”.