Skip to main content

program for operators

           Types of operators
  • binary operator
  • Arithmetic operator (+,×,÷,-)
  • Relational operator (==,=!,>, <,<=,>=)
  • conditional operator (exp1 ? exp2 : exp3;)
  • bitwise operator (&,|,^)
  • logical operator (&&,||,=!)
  • Assignment operator. (=)
Program for Arithmetic operatoraProgram for how to use Arithmetic operator.
void main ( )

{int a=5,b=7,c,d;

clrscr ( );

printf("The value of a=%d,b=%d\n",a,b);

c=a+b;

d=a*b;

printf  ("The value of c=%d and d=%d\n");

getch ( );

}

output:- The value of a=5,b=7The value of c=12 and d=35
Program for relational operators.

void main  ( )

{

int a,b;

clrscr ( );

printf ("enter two integers \n");

scanf  (" %d %d",&a,&b);

if (a>b)
printf (" %d is greater than %d\n",a,b);

else if ( a <b)

printf (" %d is less than %d\n",a,b);

else if (a==b)

printf (" %d is equal to %d\n",a,b);

getch ( );

}

output:-
enter two integers
4
5
4 is smaller than 5
4 is equal to 5.
void main ( )
{
int a=5,b=7,c,d;
clrscr ( );
printf("The value of a=%d,b=%d\n",a,b);
if(a>b) 
printf  ("%d is greater than %d",a,b) ;

else

 printf  (" %d is smaller than %d",a,b);
getch ( );
}
output:-
The value of a=5,b=7
5is smaller than 7

Program for bitwise operatorvoid main ( )
{
int a=23,b=56,c,d;
clrscr ( );
printf("The value of a=%d,b=%d\n",a,b);
c=a&b;
d=a|b;
printf  ("The value of c=%d and d=%d\n");
getch ( );
}
output :-
The value of a=23,b=56
the value of c=16 and d = 63

Program for logical operatorsvoid main ( )
{
int a=5,b=7,c=8,d;
clrscr ( );
printf("The value of a=%d,b=%d, c=%d\n",a,b,c);
c=a+b;
d=(a>b)&&(b <c)
printf  ("The value of d=%d\n");
getch ( );
}
 output :-
The value of a=5,b=7,c=8
The value of d=0




Comments

Popular posts from this blog

history of c

                 History of c programming language. 1.   First language is ALGOL come in 1960. 2.   After algol the bcpl language is come in 1967. BCPL is invented by Martin Richard.     Martin Richards (born 21 July 1940) is a British computer scientist known       for his development of the BCPL programming language in 1966. Developer of BCPL is Martin Richard in 1966. Full form of BCPL is basic combined programming language. 3.   In 1970 B language is developed in  AT & T’s bell laboraties of USA.B language is        invented by ken Thompson.                                                             4.   To improve b language then come the c language 1972 in AT & T’s Bell laboraties of usa. C is develop by Dennis Ritchie.                                               After the ken Thompson the Dennis Ritchie is developer of C language                and improve the unix operating syste

basic of programming

About c language. Q: what is c programming?   Ans: C is general purpose programming language used for wide range of application from operating system like window, linux and ios . C is a programming language developed at AT & T’s bell laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie.                                                                                          Q: why c is so popular ? Ans: C language is popular because it is easy to use and reliable , simple.                            Use of c programming language 1.   It is use for operating system (os) like window , linux ,       unix are written in c. 2.  The android core library written in c. 3.  Oracle software is written in c. 4.   Mobile device like smart phone and tablets become rang of      today. Also, consumer device like microwave ovens and      washing machines and digital camera are smarter day       by day.