PROGRAM TO SHOW THE USE OF CONDITIONAL OPERATOR

/*PROGRAM TO SHOW THE USE OF CONDITIONAL OPERATOR*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf(“Enter any two numbers to check which of them is greater: “); scanf(“%d%d”,&a,&b); c=(a>b)?a:b;          …

PROGRAM TO FIND GREATEST AMONG THREE NUMBERS

/*PROGRAM TO FIND GREATEST AMONG THREE NUMBERS*/ #include<stdio.h> #include<conio.h> void main() { float a,b,c; clrscr(); printf(“Enter any three numbers: “); scanf(“%f%f%f”,&a,&b,&c); if((a==b)&&(a==c)) printf(“Numbers are equal.\n”); else { if((a>b) && (a>c)) …

PROGRAM TO PRINT TABLE OF ANY NUMBER

/*PROGRAM TO PRINT TABLE OF ANY NUMBER*/ #include<stdio.h> #include<conio.h> void main() { int n,i,a=1; clrscr(); printf(“Enter any number: “); scanf(“%d”,&n); printf(“Table of %d is:\n”,n); for(i=1;i<=10;i++) { a=n*i; printf(“\t%d * %d …

PROGRAM TO PRINT SUM OF FIRST N ODD NATURAL NUMBERS

/*PROGRAM TO PRINT SUM OF FIRST N ODD NATURAL NUMBERS*/ #include<stdio.h> #include<conio.h> void main() { int n,i,sum=0; clrscr(); printf(“Enter the number: “); scanf(“%d”,&n); printf(“\nFirst %d odd natural numbers are: \n”,n); …

PROGRAM TO FIND THE ROOTS OF A QUADRATIC EQUATION

/*PROGRAM TO FIND THE ROOTS OF A QUADRATIC EQUATION*/ #include<stdio.h> #include<conio.h> #include<math.h> void main() { float a,b,c,d,alpha,beta; clrscr(); printf(“enter the value of a, b and c: “); scanf(“%f%f%f”,&a,&b,&c); d=(b*b)-(4*a*c); if(d<0) …

PROGRAM TO CONVERT AGE FROM YEARS INTO SECONDS

/*PROGRAM TO CONVERT AGE FROM YEARS INTO SECONDS*/ #include<stdio.h> #include<conio.h> void main() { long int a,age; clrscr(); printf(“Enter your age :”); scanf(“%ld”,&age); if(age<=0) printf(“Enter valid data only\n”); else { a=(age*365*24*60*60); …

PROGRAM TO CALCULATE GROSS SALARY OF AN EMPLOYEE

/*PROGRAM TO CALCULATE GROSS SALARY OF AN EMPLOYEE*/ #include<stdio.h> #include<conio.h> void main() { float da,hr,bp,gs; clrscr(); printf(“Enter the basic pay of employee:”); scanf(“%f”,&bp); hr=bp*20/100; da=bp*50/100; gs=bp+da+hr; printf(“Basic pay: %.2f\n”,bp); printf(“HR: …

PROGRAM TO FIND REVERSE OF A NUMBER

/*PROGRAM TO FIND REVERSE OF A NUMBER*/ #include<stdio.h> #include<conio.h> void main() { int n,rev=0,rem,temp; clrscr(); printf(“Enter any number: “); scanf(“%d”,&n); temp=n; while(temp>0) { rem=temp%10; temp=temp/10; rev=rev*10+rem; } printf(“Reverse of %d …

PROGRAM TO SWAP TWO NUMBERS WITHOUT USING THIRD VARIABLE

/*PROGRAM TO SWAP TWO NUMBERS WITHOUT USING THIRD VARIABLE*/ #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf(“Enter any two numbers: “); scanf(“%d%d”,&a,&b); printf(“Before swapping numbers were: \n”); printf(“\ta=%d and …