0% found this document useful (0 votes)
17 views6 pages

10 Operators Programs

The document contains multiple C programming code snippets demonstrating various operators, including arithmetic, relational, logical, unary, conditional, bitwise, assignment, comma, and size of operators. Each section provides a brief example of how to use the respective operator, along with input and output statements. The examples illustrate fundamental programming concepts and operations in C.

Uploaded by

mohankumar.g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

10 Operators Programs

The document contains multiple C programming code snippets demonstrating various operators, including arithmetic, relational, logical, unary, conditional, bitwise, assignment, comma, and size of operators. Each section provides a brief example of how to use the respective operator, along with input and output statements. The examples illustrate fundamental programming concepts and operations in C.

Uploaded by

mohankumar.g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Arithmetic operator

#include<stdio.h>

int main()

int num1,num2;

printf("enter any two numbers:");

scanf("%d%d",&num1,&num2);

printf("\n the result of addition is:%d+%d=%d",num1,num2,num1+num2);

printf("\n the result of subtraction is:%d-%d=%d",num1,num2,num1-num2);

printf("\n the result of multiplication is:%d*%d=%d",num1,num2,num1*num2);

printf("\n the result of division is:%d/%d=%d",num1,num2,num1/num2);

printf("\n the result of modulus is:%d%%%d=%d",num1,num2,num1%num2);

return 0;

2,[Link] and equality operator

#include<stdio.h>

int main()

int x=10,y=20;

printf("%d<%d=%d\n",x,y,x<y);

printf("%d>%d=%d\n",x,y,x>y);

printf("%d<=%d=%d\n",x,y,x<=y);

printf("%d>=%d=%d\n",x,y,x>=y);

printf("%d==%d=%d\n",x,y,x==y);

printf("%d!=%d=%d\n",x,y,x!=y);

return 0;

}
[Link] Operator

#include<stdio.h>

int main()

int x=5,y=8;

printf("And result=%d\n", x>10&&y<10);

printf("Or result=%d\n", x>2||y<10);

printf("Not result=%d\n", !(x>4));

return 0;

[Link] increment and decrement operator

#include<stdio.h>

int main()

int num=3;

printf("the value of num=%d",num);

printf("the value of ++num=%d",++num);

printf("the new value of num=%d",num);

printf("the value of num=%d",num);

printf("the value of --num=%d",--num);

printf("the new value of num=%d",num);

printf("the value of num=%d",num);

printf("the value of num++=%d",num++);


printf("the new value of num=%d",num);

printf("the value of num=%d",num);

printf("the value of num--=%d",num--);

printf("the new value of num=%d",num);

return 0;

[Link] operator

#include<stdio.h>

int main()

int num1,num2,num3,large;

printf("enter the three numbers");

scanf("%d%d%d",&num1,&num2,&num3);

large=num1>num2?(num1>num3?num1:num3):(num2>num3?num2:num3);

printf("the largest number is:%d",large);

return 0;

[Link] operator

#include<stdio.h>

int main()

int a=10,b=12;

printf("\n a&b=%d",a&b);

printf("\n a|b=%d",a|b);

printf("\n ~a=%d",~a);
printf("\n ~b=%d",~b);

printf("\n a^b=%d",a^b);

printf("\n a<<1=%d",a<<1);

printf("\n a>>1=%d",a>>1);

printf("\n b<<1=%d",b<<1);

printf("\n b>>1=%d",b>>1);

return 0;

[Link] Operator

#include <stdio.h>

int main()

int a, b;

a = 10; // assigning value 10 to a

b = 20; // assigning value 20 to b

printf("Value of a = %d\n", a);

printf("Value of b = %d\n", b);

return 0;

[Link] Operator

#include <stdio.h>
int main()

int a, b,c;

a = 10; // assigning value 10 to a

b = 20; // assigning value 20 to b

c = a+b;

printf("Value of a = %d\n", a);

printf("Value of b = %d\n", b);

printf("Value of c = %d\n", c);

return 0;

[Link] of Operator

#include <stdio.h>

int main()

int a;

float b;

char c;

double d;

long double e;

printf("Size of int = %d bytes\n", sizeof(a));

printf("Size of float = %.f bytes\n", sizeof(b));

printf("Size of char = %lu bytes\n", sizeof(c));


printf("Size of double = %lu bytes\n", sizeof(d));

printf("Size of long double = %lu bytes\n", sizeof(e));

return 0;

You might also like