Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 14

Area of Circle

/*TO FIND THE AREA AND CIRCUMFERENCE OF THE CIRCLE*/


#include<stdio.h>
main()
{
float radius,area,circum;
printf(\nEnter the radius of the circle);
scanf(%f,&radius);
area=3.14*radius*radius;
circum=2*3.14*radius;
printf(\nArea=%f,area);
//printf(\nCircumference=%f,circum);
}
OUTPUT:
Enter the radius of the circle
7
Area=153.86

Temperature Conversion
LOGIN: Balaji
/*TEMPERATURE CONVERSION*/
#include<stdio.h>
main()
{
float celcius,fahren,c,f;
clrscr();
printf(\n Tempterature Conversion);
printf(\nEnter the fahrenheit value:);
scanf(%f,&f);
celcius=(9.0/5.0)*(f-32);
printf(Celcius=%d,celcius);
printf(\nEnter the celcius value:);
scanf(%f,&c);
fahren=(9.0/5.0)*c+32;
printf(Fahrenheit=%d,fahren);
getch();
}
OUTPUT:

Enter the fahrenheit value:5


Celsius=-1.5
Enter the celcius value:14
Fahrenheit=50.00

Evaluate the given Expression


LOGIN: SURESH
/* Expression Evaluation*/
#include<stdio.h>
main()
{
int a,b,c;
float x,y,z;
printf ("Enter the values for a,b,c \n");
scanf("%d,%d,%d", &a,&b,&c);
x = (a * b) c;
y = (b/c) * a;
z = (a - b) / (c + d)
printf(" The value of x is ,x the value of y is ,y The value of z is ,z );
}
OUTPUT:
Enter the value for a,b,c.
a= 5; b = 6; c= 12;
x = 28.000;
y = 2.5000
z = 0.0555

Find the Given year is Lear Year or Not


#include<stdio.h>
main()
{
int ye;
printf ("Enter the year \n");
scanf("%d", &ye);
if (ye%4==0)
printf("It is a Leap Year \n");
else
printf("It is Not a Leap Year\n");
}

OUTPUT:
Enter the year 2000
It is a Leap Year
Enter the year 1995
It is Not a Leap Year

Largest of three numbers


/*TO FIND THE AREA AND CIRCUMFERENCE OF THE CIRCLE*/
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf(Biggest of three Nos);
printf(Enter the values of A,B,C);
scanf(%d%d%d,&a,&b,&c);
if((a>b)&&(b>c))
printf(\n a=%d is greatest,a);
elseif(b>c)
{
printf(\n b=%d is greatest,b);
}
else
{
printf(\n c=%d is greatest,c);
}
getch();
}
OUTPUT:
Enter the values of A,B,C:50 90 120
C=120 is greatest

Age-Height Evaluation Program


#include<stdio.h>
#include<conio.h>
main()
{

int age,height;
clrscr();
printf("\n Enter the age (in the range of 2 - 5 )and height ");
scanf("%d%d",&age,&height);
if(age<4)
{
if(height<55)
printf("\n the height is short");
else if((height >=55)&&(height < 75))
printf("\n the height is normal");
else
printf("\n the height is tall");
}
else
{
if(height<75)
printf("\n the height is short");
else if((height >=75)&&(height < 100))
printf("\n the height is normal");
else
printf("\n the height is tall");
}
getch();
}
OUTPUT:
Enter the age (in the range of 2 5) and height
2
65
the height is normal
Enter the age (in the range of 2 5) and height
5
120
the height is tall

Find the Given number is palindrome or Not


/* PROGRAM TO FIND THE SUM AND REVERSE OF THE GIVEN NUMBER*/
#include<stdio.h>
main()
{
unsigned long int a,num,sum=0,rnum=0,rem;
printf(\nEnter the number...);
scanf(%ld,&num);
a=num;
while(num!=0)
{
rem=num%10;
sum=sum+rem;
rnum=rnum*10+rem;
num=num/10;
}
printf(\nThe sum of the digits of %ld is %ld\n,a,sum);
printf(\nThe reverse number of the %ld is %ld,a,rnum);
if(a==rnum)
printf(\nThe given number is a palindrome);
else
printf(\nThe given number is not a palindrome);
}
OUTPUT:
Enter the number...12321
The sum of the digits of 12321 is 9
The reverse number of the 12321 is 12321
The given number is a palindrome

Generate Armstrong Series between a Range


/* PROGRAM TO ARMSTRONG SERIES WITHN A RANGE*/
#include<stdio.h>
main()
{
int number, temp, digit1, digit2, digit3;
printf("Printing all Armstrong numbers between 1 and 500:\n\n");
number = 001;
while (number <= 500)
{
digit1 = number - ((number / 10) * 10);
digit2 = (number / 10) - ((number / 100) * 10);
digit3 = (number / 100) - ((number / 1000) * 10);
temp = (digit1*digit1*digit1) + (digit2*digit2*digit2) + (digit3*digit3*digit3);
if (temp == number)
{
printf("\nAmstrong Number:%d", temp);

}
number++;
}
}
OUTPUT:
Printing all Armstrong numbers between 1 and 500
Amstrong Number:1
Amstrong Number:153
Amstrong Number:370
Amstrong Number:371

Multiplication of two matrices


// MULTPLICATION OF TWO MATRIX
#include<stdio.h>
main()
{
int a[25][25],b[25][25],c[25][25],i,j,k,r,s;
int m,n;
printf(\nEnter the Rows and Columns of A matrix...);
scanf(%d %d,&m,&n);
printf(\nEnter the Rows and Columns of B matrix...);
scanf(%d %d,&r,&s);
if(m!=r)
printf(\nThe matrix cannot multiplied);
else
{
printf(\nEnter the elements of A matrix);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf(\t%d,&a[i][j]);
}
printf(\nEnter the elements of B matrix);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf(\t%d,&b[i][j]);
}
printf(\nThe elements of A matrix);
for(i=0;i<m;i++)
{
printf(\n);
for(j=0;j<n;j++)
printf(\t%d,a[i][j]);
}
printf(\n The elements of B matrix);
for(i=0;i<m;i++)
{

printf(\n);
for(j=0;j<n;j++)
printf(\t%d,b[i][j]);
}
for(i=0;i<m;i++)
{
printf(\n);
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<m;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(The multiplication of two matrixes);
for(i=0;i<m;i++)
{
printf(\n);
for(j=0;j<n;j++)
printf(\t%d,c[i][j]);
}
}
OUTPUT
Enter the Rows and Columns of A matrix... 3 3
Enter the Rows and Columns of B matrix... 3 3
Enter the elements of A matrix 1 2 3 4 5 6 7 8 9
Enter the elements of B matrix 1 2 3 4 5 6 7 8 9
The elements of A matrix
1
2
3
4
5
6
7
8
9
The elements of B matrix
1
2
3
4
5
6
7
8
9
The multiplication of two matrixes
30
36
42
66
81
96
102
126
150

Arithmetic Opertions Using Switch Case


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;

char op;
clrscr();
printf("\n Arithemetic Operations using switch case");
printf("\nEnter the value of a and b");
scanf("%d%d",&a,&b);
printf("\nSelect the operation u want");
printf("\n+.Add\n-.Sub\n*.Mul");
printf("\n/.Div\n%.Mod");
printf("\nEnter ur choice");
scanf("%d",&op);
switch(op)
{
case +:
c=a+b;
printf("\nThe Sum is %d",c);
break;
case -:
c=a-b;
printf("\nThe difference is %d",c);
break;
case *:
c=a*b;
printf("\nThe product is %d",c);
break;
case /:
c=a/b;
printf("\nThe Quotient is %d",c);
break;
case %:
c=a%b;
printf("\nThe Reminder is %d",c);
break;
default:
printf("\nEnter the operator to perform Arithmetic operations");
break;
}
getch();
}
OUTPUT:
Arithemetic Operation
Enter the value of a and b 40 50
Select the operation u want
+.Add
-.Sub
*.Mul
/.Div
%.Mod
Enter ur choice*

The Difference is 2000

Generating Pascal triangle


//CONSTRUCT PASCAL TRIANGLE
#include<stdio.h>
main()
{
int noline,i,j,temp;
printf(Enter the number of lines to print);
scanf(%d,&noline);
for(i=1;i<=noline;i++)
{
for(j=1;j<=noline-i;j++)
printf( );
temp=i;
for(j=1;j<=i;j++)
printf(%4d,temp++);
temp=temp-2;
for(j=1;j<i;j++)
printf(%4d,temp-);
printf(\n\n);
}
printf(\n);
}
OUTPUT:
Enter the number of lines to print 5
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5

Employee Payroll Using Structure

#include<stdio.h>
#include<conio.h>
struct employ
{
char name[40];
int Emp_no;
float basic_sal;

float net_salary;
};
void main()
{
struct employ emp;
float hra,da,det;
clrscr();
printf("\nEmployee Details");
printf("\nEnter the emp name");
scanf("%s",emp.name);
printf("\nEnter the employee no");
scanf("%d",&emp.Emp_no);
printf("\nEnter the basic salary");
scanf("%f",&emp.basic_sal);
hra=((15*emp.basic_sal)/100);
da=((10*emp.basic_sal)/100);
det=((5*emp.basic_sal)/100);
emp.net_salary=emp.basic_sal+hra+da-det;
printf("\nEmployee name:%s",emp.name);
printf("\nEmployee no:%d",emp.Emp_no);
printf("\nEmployee Basic salary:%f",emp.basic_sal);
printf("\nHRA:%f",hra);
printf("\nDA:%f",da);
printf("\nDetection:%f",det);
printf("\nGross salary:%f",emp.net_salary);
getch();
}
OUTPUT:
Employee Details
Enter the employee name aaa
Enter the employee no1000
Enter the basic salary 5000
Employee name:aaa

Employee no:1000
Employee Basic salary:5000.000000
HRA:750.00000
DA:500.000000
Detection:250.000000
Gross salary:6500.000000

Find Student Marks using Union


//STUDENT RECORD USING POINTER AND UNION
#include<stdio.h>
main()
{
union student
{
char name[25];
char regno[25];
int avg;
char grade;
} stud[50],*pt;
int i,no;
printf(Enter the number of the students...);
scanf(%d,&no);
for(i=0;i<no;i++)
{
printf(\n student[%d] information:\n,i+1);
printf(Enter the name);
scanf(%s,stud[i].name);
printf(\nEnter the roll no of the student);
scanf(%s,stud[i].regno);
printf(\nEnter the average value of the student);
scanf(%d,&stud[i].avg);
}
pt=stud;
for(pt=stud;pt<stud+no;pt++)
{
if(pt->avg<30)
pt->grade=D;
else if(pt->avg<50)
pt->grade=C;
else if(pt->avg<70)
pt->grade=B;
else

pt->grade=A;
}
printf(\n);
printf(NAME REGISTER-NO AVERAGE GRADE\n);
for(pt=stud;pt<stud+no;pt++)
{
printf(%-20s%-10s,pt->name,pt->regno);
printf(%10d \t %c\n,pt->avg,pt->grade);
}
}
OUTPUT:
Enter the number of the students
3
student[1] information:
Enter the name MUNI
Enter the roll no of the student 100
Enter the average value of the student 95
student[2] information:
Enter the name LAK
Enter the roll no of the student 200
Enter the average value of the student 55
student[3] information:
Enter the name RAJA
Enter the roll no of the student 300
Enter the average value of the student 25
NAME REGISTER-NO
AVERAGE
MUNI 100
95
A
LKA 200
55
B
RAJA

300

25

GRADE

Swapping Two Numbers (without third Variable) CALL BY VALUE


#include<stdio.h>
#include<conio.h>
main()
{
int x1,x2;
void swap(int ,int);
clrscr();
printf("\n Enter the two numbers");
scanf("%d%d",&x1,&x2);
printf("\n Before swapping the values of x1 = %d and x2 = %d",x1,x2);
swap(x1,x2);
getch();
}
void swap(int x,int y)
{
x=x+y;
y=x-y;

x=x-y;
printf("\n After swapping the values of r1 = %d and r2 = %d",x,y);
}
OUTPUT:
Enter the two numbers
15 30
Before swapping the values of r1 =15 and r2 =30
After swapping the values of r1 =30 and r2 = 15

Swapping Two Numbers Call By Reference


#include<stdio.h>
#include<conio.h>
main()
{
int r1,r2;
void swap(int *,int *);
clrscr();
printf("\n Enter the two numbers");
scanf("%d%d",&r1,&r2);
printf("\n Before swapping the value of r1= %d and r2= %d",r1,r2);
swap(&r1,&r2);
printf("\n After swapping the value of r1= %d and r2= %d",r1,r2);
getch();
}
void swap(int *a,int *b)
{
int temp;
temp= *a;
*a = *b;
*b = temp;
}
OUTPUT:
Enter the two numbers
100
200
Before swapping the value of r1 = 100 and r2 = 200
After swapping the value of r1 = 200 and r2 = 100

Factorial Computation using recursive Function


#include<stdio.h>
main()

{
int num,a;
printf(Enter the number);
scanf(%d,&num);
a=recur(num);
printf(The factorial of the number %d is %d,num,a);
}
recur(int no)
{
int fact=1;
if(no==1)
return(1);
else
fact=no*recur(no-1);
}
OUTPUT:
Enter the number 5
The factorial of the number 5 is 120

You might also like