next


Hello World Program
Unary Operators


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Welcome to  Hello World ");
getch();
}

UnaryMinus

/* Unary minus Program*/

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
printf("The sign value is %d",-x);
getch();
}

PreIncrement Operaator(++x)

/* Unary PreIncrement Program*/

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
printf("The sign value is %d",++x);
getch();
}

PostIncrement Operaator(x++)

/* Unary PostIncrement Program*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
printf("The sign value is %d",x++);
getch();
}

PreDecrement Operaator(- -x)


/* Unary PreDecrement Program*/

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
printf("The sign value is %d",--x);
getch();
}

PostDecrement Operaator(x- -)

/* Unary PostDecrement Program*/
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
printf("The PostDecrement value is %d",x--);
printf("\n The x Value Is %d",x);
getch();
}

Arithmetic Operators
Binary Operators

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,add,sub,mul,div,mod;
printf("enter x,y values");
scanf("%d%d",&x,&y);
add=x+y;
sub=x-y;
mul=x*y;
div=x/y;
mod=x%y;

printf("\nAddtion of two numbers is %d",add);
printf("\nSubstraction of two numbers is %d",sub);
printf("\nmultiplication of two numbers is %d",mulf);
printf("\nDivision of two numbers is %d",div);
printf("\nModular Division of two numbers is %d",mod);
getch();
}

Swaping Of Two Numbers

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,temp;
printf("enter x,y values");
scanf("%d%d",&x,&y);
printf("\n before swaping\n x value= %d\n y value=%d",x,y);
temp=x;
x=y;
y=temp;
printf("\n after swaping\n x value= %d\n y value=%d",x,y);

getch();
}

Swaping Of Two Numbers Without Using Third Variable
                                
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y;
printf("enter x,y values");
scanf("%d%d",&x,&y);
printf("\n before swaping\n x value= %d\n y value=%d",x,y);
x=x+y;
y=x-y;
x=x-y;
printf("\n after swaping\n x value= %d\n y value=%d",x,y);

getch();
}

Relational Operators

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,equal,greater,lesser,greaterequal,lesserequal,notequal;
printf("enter x,y values");
scanf("%d%d",&x,&y);
equal = x ==y;
greater = x > y;
lesser = x < y;
greaterequal = x>=y;
lesserequal = x <= y;
notequal = x!=y;

printf("\nThe value of x==y = %d", equal);
printf("\nThe value of x>y = %d", greater);
printf("\nThe value of x<y = %d", lesser);
printf("\nThe value of x>=y = %d", greaterequal);
printf("\nThe value of x<=y = %d", lesserequal);
printf("\nThe value of x!=y = %d", notequal);
printf("\ntrue =1 \n false =0 ");
getch();
}

Bitwise Operators

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,and,or,cap,nagetion,leftshift,rightshift;
printf("enter x,y values");
scanf("%d%d",&x,&y);
and=x&y;
or=x|y;
cap=x^y;
nagetion=~x;
leftshift=x<<2;
rightshift=x>>2;

printf("\nbitwise  x&y = %d",and);
printf("\nbitwise  x|y = %d",or);
printf("\nbitwise  x^y= %d",cap);
printf("\nbitwise  ~ = %d",nagetion);
printf("\nbitwise  x<<2 = %d",leftshift<<2);
printf("\nbitwise  x>>2 = %d",rightshift>>2);

getch();
}

ODD or EVEN using ternary
Ternary Operators

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter x value");
scanf("%d",&x);
x%2==0? printf("Even Number"):printf("Odd Number");
getch();
}

Max Number Using Ternary

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y;
printf("enter x,y values");
scanf("%d %d",&x,&y);
x>y? printf("X is max"):printf(" y is max");
getch();
}

Odd or Even number Using IF-ELSE
Conditional

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n;
printf("Enter n value");
scanf("%d",&n);
if(n%2==0)
{
printf("Even number");
}
else
{
printf("Odd number");
}
getch();
}

Max Number Program Using IF-ELSE

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y;
printf("Enter x,y value");
scanf("%d%d",&x,&y);
if(x>y)
{
printf("X is max");
}
else
{
printf("Y is max");
}
getch();
}

Check The Given Number Is Valid Or Invalid (Value Must be 20 To 30 Between

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("Enter x value");
scanf("%d",&x);
if(x>=20 && x<=30)
{
printf("Valid number");
}
else
{
printf("Invalid  number");
}
getch();
}

Voewl Consonant Program Using IF-ELSE

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
printf("Enter charactor");
scanf("%c",&ch);
if(ch>='a' && ch<='z')
{
if(ch=='a'|| ch=='e'||ch=='i'||ch=='o'||ch=='u')
{
printf("Vowel");
}
else
{
printf("Consonant");
}
}
else
{
printf("Please enter Small letters only");
}
getch();
}

Check Your Age Program using ELSE-IF

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int age;
printf("Enter your age");
scanf("%d",&age);
if(age>0&& age<=12)
{
printf("You are a child age");
}
else if(age>12 && age<=19)
{
printf("You are a teenage");
}
else if(age>19 && age<=40)
{
printf("You are a Younger");
}
else if(age>40 && age<=80)
{
printf("You are a oldage");
}
else if(age>80 && age<=100)
{
printf("You are a too oldage");
}
else
{
printf("Invalid age");
}
getch();
}

Nested IF Condition

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int age;
printf("Enter your age");
scanf("%d",&age);
if(age>0)
{
if(age>0&& age<=12)
{
printf("You are a child age");
}
else if(age>12 && age<=19)
{
printf("You are a teenage");
}
else if(age>19 && age<=40)
{
printf("You are a Younger");
}
else if(age>40 && age<=80)
{
printf("You are a oldage");
}
else if(age>80 && age<=100)
{
printf("You are a too oldage");
}
else
{
printf("Invalid age");
}
}
else
{
printf("Age should not be negetive");
}
getch();
}

Max Number Program Using Amoung Three Numbers

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
printf("Enter x,y ,z values");
scanf("%d%d%d",&x,&y,&z);
if(x>y && x>z)
{
printf("x is max");
}
else if(y>x && y>z)
{
printf("y is max");
}
else if(z>x && z>y)
{
printf("z is max");
}
else
{
printf("Invalid Number");
}
getch();
}

Vowel Consonant Program Using Switch

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
printf("enter Character");
scanf("%c",&ch);
switch(ch)
{
case 'a':
     
case 'e':
       
case 'i':
      
case 'o':
       
case 'u':
       printf("vowel");
       break;
default:
	printf("consonent");
}
getch();
}

Simple Calculator Program Using Switch

#include<stdio.h>
#include<conio.h>
void main()
{
int x;
int y;
int z;
printf("1.addition");
printf("\n2.subtraction");
printf("\n3.multplication");
printf("\n4.divsioni");
printf("\n5.modular division");
printf("enter your choice");
scanf("%d",&z);
printf("enter x,y");
scanf("%d%d",&x,&y);
switch(z)
{
case 1:

      printf("addition %d",x+y);
      break;
case 2:
       printf("sudtrction %d",x-y);
       break;
case 3:
       printf("multiplication %d",x*y);
       break;
case 4:
       printf("division %d",x/y);
       break;
case 5:
       printf("modular division %d",x%y);
       break;
default:
	printf("invalied choice");
}
getch();
}

ODD or Even Number Program Using Switch

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
printf("enter x");
scanf("%d",&x);
y=x%2;
switch(y)
{
case 0:
       printf("Even");
       break;
case 1:
       printf("Odd");
       break;
default:
	printf("Invalid Choice");
}
getch();
}

Display 1 TO 10 Numbers Using FOR-LOOP
For Loop

#include<stdio.h>
#include<conio.h>
void main()
{
int x;
for(x=1;x<=10;x++)
{
printf("\n%d",x);
}
getch();
}

Display 10 To 1 Values Using FOR-LOOP

#include<stdio.h>
#include<conio.h>
void main()
{
int x;
for(x=10;x>=1;x--)
{
printf("%d",x);
}
getch();
}