Welcome !!

NICETECHVIDYA

Tutorials

Web Designs

You are welcome to Aptech Designers, designed by Pratik from Nepal.

Creativity is my passion. Logo describes your details about company.

Graphics Design needs vision to create yours unique digital concept.

Responsive and All Browser Compatible Dynamic Web Layouts our target.

Home Python C Language J A V A Our Courses
This WebSite is under Construction....

Thursday, 10 March 2022

18.Trigraph/Digraph characters (Not for Turbo C)

 

Trigraph/Digraph characters: (Not for Turbo C)

A trigraph is a combination of three characters.

A trigraph sequence found in the source code is converted to its respective translation character.

This allows people to enter certain characters that are not allowed under some (rare) platforms.

In 1994 C standards supplied digraphs as more readable alternatives to five of the trigraph characters.

Note: These don’t work under turbo c platform.

 

Trigraph sequence

Digraph

Equal character

??=

% :

#

??(

< :

[

??)

:>

]

??/

 

\

??<

<%

{

??>

%>

}

??!

 

|

??’

 

^

??-

 

~

 

Example:


#include<stdio.h>
void main()
{
printf(“Hello??/nWorld”);
}                                                 


The above source code is translated into


#include<stdio.h>
void main()
{
printf(“Hello\nWorld”);
}


Output:

Hello

World

 

 

Points to remember :

Constants can be directly used in printf statement

 

Example :

#include<stdio.h>
void main()
{
clrscr();
printf(“%d”,10);
printf(“\n%f”,12.25);
printf(“\n%c”,’x’);
printf(“\n%d”,’a’);      /* prints the ASCII value of ‘a’ */
getch();
}

Output:

10

12.250000

x

97

 

Expressions can be directly used in printf statement:

 

Example :

#include<stdio.h>
void main()
{
int x,y;
clrscr();
x=5;
y=2;
printf(“Sum=%d”,x+y);
printf(“\n subtraction=%d”,x-y);
printf(“\n product=%d”,x*y);
printf(“\n division=%f”,(float)x/y);
getch();
}

Output:

Sum=7

Subtraction=3

Product=10

Division=2.500000

When a variable is not declared, then it gives error.


Example :

#include<stdio.h>
void main()
{
int a,b;
clrscr();
printf(“Enter two numbers:”);
scanf(“%d%d”,&a,&b);
c=a+b;
printf(“Sum=%d”,c);
getch();
}

Output:

Error: Undefined symbol ‘c’ in function main()

Assigning a value while declaration of a variable is called initializing

 

Example :

#include<stdio.h>
void main()
{
int x=5,y=2,z=x+y;
clrscr();
printf(“Sum=%d”,z);
getch();
}

Output:

Sum=7

When a variable is not initialized or assigned with any value, then it is initialized with an unknown value called garbage value.

 

Example :

#include<stdio.h>
void main()
{
int x;
clrscr();
printf(“%d”,x);
getch();
}

Output:

-25524 (Changes machine to machine and execution to execution)

 

0 comments:

Post a Comment