Ex No: Date: 2.1.expression Evaluation

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

EX NO:

DATE: 2.1.EXPRESSION EVALUATION

/*Program for Expression Evaluation*/

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c,y;
clrscr();
printf("Enter the value of a,b and c\n");
scanf("%d%d%d" ,&a,&b,&c);
y=a+b/c-a%c+2*a;
printf("the result of the expression is %d\n\n\n",y);

a=10;
printf("The value of a is %d\n",a);
printf("The value of preincrement operator is %d\n",++a);
printf("The value of a is %d\n",a);
printf("The value of postincrement operator is %d\n",a++);
printf("The value of a is %d\n",a);
printf("The value of predecrement operator is %d\n",--a);
printf("The value of a is %d\n",a);
printf("The value of postdecrement operator is %d\n",a--);
printf("The value of a is %d\n",a);
getch();
}
EX NO:
DATE: 2.1.EXPRESSION EVALUATION

OUTPUT:

Enter the value of a,b and c


4
5
7
the result of the expression is 8

The value of a is 10
The value of preincrement operator is 11
The value of a is 11
The value of postincrement operator is 11
The value of a is 12
The value of predecrement operator is 11
The value of a is 11
The value of postdecrement operator is 11
The value of a is 10
EX NO:
DATE: 2.2.CONVERSION BETWEEN CELSIUS TO FAHRENHEIT

/*program to convert Celsius to Farenheit and vice-versa*/

#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("Enter the Degree Celsius Value\n");
scanf("%f",&c);
f=(1.8*c)+32;
printf("the Farenheit Value for %.2f celsius is %.2f \n",c,f);

printf("Enter the Farenheit Value\n");


scanf("%f",&f);
c=(f-32)/1.8;
printf("the Celsius Value for %.2f Farenheit is %.2f\n",f,c);
getch();
}

OUTPUT:

Enter the Degree Celsius Value


45
the Farenheit Value for 45.00 celsius is 113.00
Enter the Farenheit Value
98
the Celsius Value for 98.00 Farenheit is 36.67
EX NO:
DATE: 2.3.AREA OF A CIRCLE AND TRIANGLE

//Program to find the Area of circle and triangle

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.14

void main()
{
float AC,s,AT,t,r,a,b,c,f;
clrscr();
//Area of a circle
printf("Area of the Circle\n");
printf("Enter the radius of the circle\nr=");
scanf("%f",&r);
AC=pi*r*r;
printf("The Area of the circle is %f\n",AC);
//Area of a triangle
printf("Area of the Triangle\n");
printf("Enter the a,b,c values\n");
scanf("\n%f\n%f\n%f",&a,&b,&c);
printf("The value of s=");
s=(a+b+c)/2;
printf("%f",s);
t=s*(s-a)*(s-b)*(s-c);
AT=sqrt(t);
printf("\nThe area of the triangle is %f",AT);
getch();
}
OUTPUT:

Area of the Circle


Enter the radius of the circle
r=2
The Area of the circle is 12.560000
Area of the Triangle
Enter the a,b,c values
2
3
4
The value of s=4.500000
The area of the triangle is 2.904737
EX NO:
DATE: 2.3.MATHEMATIC FUNCTIONS

/* program to imply mathematic functions*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,p;
float n,sn,r,d;
clrscr();

//Square Root of a number


printf("Enter the n value\n");
scanf("%f",&n);
sn=sqrt(n);
printf("The squareroot of %f is %f \n",n,sn);

//power of a number
printf("\nEnter the base and power value\n");
scanf("%d%d",&a,&b);
p=pow(a,b);
printf("The power is %d \n",p);

//Trignometric Functions
printf("\nEnter the Radians value\n");
scanf("%f",&r);
d=(180/3.14)*r;
printf("The degree value is %f\n",d);
printf("\nThe cosine value is %f\n",cos(d));
printf("The sine value is %f\n",sin(d));
printf("The tan value is %f\n",tan(d));

getch();

}
EX NO:
DATE: 2.3.MATHEMATIC FUNCTIONS

OUTPUT:

Enter the n value


5
The squareroot of 5.000000 is 2.236068

Enter the base and power value


4
2
The power is 16

Enter the Radians value


1.05
The degree value is 60.191078

The cosine value is -0.877190


The sine value is -0.480143
The tan value is 0.547365

You might also like