Professional Documents
Culture Documents
Lecture – 1
Highlights
Multiple Printf(); and make the program more efficient using escape sequence
Q/A Session
By: Ameen Khowaja
(Lecturer CS)
First Progarm in C Continued
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf(“SMI University”);
getch();
}
Output of Program
SMI University
Alma Mater of Quaid-e-AzaM
#include<stdio.h>
Multiple printf() for multiple text
#include<conio.h>
void main()
Who will find the error in the
{
program
clrscr();
\n
Type of error????
Output of Program
SMI University
Alma Mater of Quaid-e-Azam
Multiple printf() for multiple text
#include<stdio.h>
Yes
#include<conio.h>
void main() \n will be used
{
clrscr();
printf(“SMI University \n”);
printf(“Alma Mater of Quaid-e-Azam “);
getch();
}
Output of Program
SMI University
Alma Mater of Quaid-e-Azam
\n will break the text and set focus on new line
Printf(); with Tab
#include<stdio.h> indentation
#include<conio.h>
\t is used for tab indentation
void main()
{ Normally equal to 5 spaces
clrscr();
printf(“SMI \t University \t”);
printf(“Alma Mater of Quaid-e-Azam \n”);
printf(“MURAD MUHAMMAD”);
getch();
}
Output of Program
SMI University Alma Mater of Quaid-e-Azam
\t will create a gap between two strings
Escape Sequences
\n for new line
\t Horizontal tab. Move the cursor to the next tab
\a Alert – produces a sound or visible alert without
changing the current cursor position.
\\ Backslash- Insert a backslash character in a string
\” Double quote – Insert a double-quote character in string.