North South University
Department of Electrical and Computer Engineering
CSE 115L (Programming Language I Lab)
Lab 2: Console Output and Escape Sequences
Objective:
● Understanding Console Output: Demonstrate basic console output operations using
printf and escape sequences.
Escape Sequences:
The backslash is followed by a specific character to represent special characters. Below are
commonly used escape sequences:
Escape Sequence Description Example
\n Newline (moves to the next printf("Hello\nWorld!");
line)
\t Horizontal tab printf("A\tB\tC");
\" Double quotation mark printf("He said, \"Hello!\"");
\' Single quotation mark printf("He said, \'Hello!\'");
\r Carriage return printf("Hello\rWorld");
\b Backspace printf("ABC\bD");
Example:
#include <stdio.h>
int main(void) {
// Using escape sequences
printf("Hello, World!\n"); // Prints a newline
printf("Tab\tSpace\n"); // Adds a tab
printf("Double Quote: \"\n"); // Prints a double quote
printf("Hello\rWorld");
return 0;
}
Classwork:
1. Write a program that prints a tabular output like below.
2. Write a program to print the below information exactly the same as given
3. Write a program to print the below information exactly the same as given
4. Write a program that prints "Processing..." and then immediately overwrites it with
"Done!"