Escape Sequence in C
Escape sequence in C is a sequence of characters that doesn't represent itself it is used before or after the character.
List of Escape Sequences in C
Escape Sequence Meaning
\b Backspace
\n New Line
\a Alarm or Beep
\f Form Feed
\r Carriage Return
\t Tab (Horizontal)
\v Vertical Tab
\\ Backslash
\' Single Quote
\" Double Quote
\? Question Mark
\nnn octal number
\xhh hexadecimal number
\0 Null
Write a program to print sum, subtract, multiply, division of two number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\tEnter the two number \n\n\b ");// Escape Sequences
scanf("%d %d",&a, &b);
c=a+b;
printf("\n sum of two number = %d ",c);
c=a-b;
printf("\n Subtraction of two number = %d ",c);
c=a*b;
printf("\n Multiplication of two number = %d ",c);
c=a/b;
printf("\n Division of two number = %d ",c);
getch();
}
Output:-
Enter the two number
7
8
sum of two number = 15
Subtraction of two number = -1
Multiplication of two number = 56
Division of two number = 0
Write a program to print sum of two number using increment operator
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the two number ");
scanf("%d %d",&a, &b);
c=a+b;
printf("\n sum of two number = %d ",c);
c++; //Increment operator
printf("\n Increment of two number = %d \t ",c);// Escape Sequences
getch();
}
Output:-
Enter the two number 6
8
sum of two number = 14
Increment of two number = 15
Comments in C
Escape sequence in C is a sequence of characters that doesn't represent itself it is used before or after the character.
List of Escape Sequences in C
Escape Sequence Meaning
\b Backspace
\n New Line
\a Alarm or Beep
\f Form Feed
\r Carriage Return
\t Tab (Horizontal)
\v Vertical Tab
\\ Backslash
\' Single Quote
\" Double Quote
\? Question Mark
\nnn octal number
\xhh hexadecimal number
\0 Null
Write a program to print sum, subtract, multiply, division of two number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\tEnter the two number \n\n\b ");// Escape Sequences
scanf("%d %d",&a, &b);
c=a+b;
printf("\n sum of two number = %d ",c);
c=a-b;
printf("\n Subtraction of two number = %d ",c);
c=a*b;
printf("\n Multiplication of two number = %d ",c);
c=a/b;
printf("\n Division of two number = %d ",c);
getch();
}
Output:-
Enter the two number
7
8
sum of two number = 15
Subtraction of two number = -1
Multiplication of two number = 56
Division of two number = 0
Write a program to print sum of two number using increment operator
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the two number ");
scanf("%d %d",&a, &b);
c=a+b;
printf("\n sum of two number = %d ",c);
c++; //Increment operator
printf("\n Increment of two number = %d \t ",c);// Escape Sequences
getch();
}
Output:-
Enter the two number 6
8
sum of two number = 14
Increment of two number = 15
Comments in C
No comments:
Post a Comment