Professional Documents
Culture Documents
List of Small Programmes
List of Small Programmes
MVP Samaj’s
KTHM College, Nashik
Department of Statistics
clrscr();
float b,ht;
printf("enter the base of triangle\n");
scanf("%f",&b);
printf("enter the height of triangle");
scanf("%f",&ht);
area=0.5*b*ht;
printf("area of trianglr %f is",area);
getch();
}
OR
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,s,area;
printf("Enter three sides of triangle \n");
scanf("%f%f%f",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle is %f ",area);
getch();
}
void main()
{
clrscr();
int x,y;
printf("Enter two numbers \n");
scanf("%f%f",&x,&y);
if(x>y)
{
printf("%d is the maximum number",x);
}
if(x<y)
{
printf("%d is the minimum number",x);
}
else
{
printf("Two numbers are equal");
}
getch();
}
void main()
{
clrscr();
int a,b,c,d;
float r1,r2;
printf("Enter the coefficients a,b and c\n");
scanf("%d %d %d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d > 0)
{
r1=(-b+(sqrt(d)))/(2*a);
printf("Roots of quadratic equation %f and %f",r1,r2);
}
else
{
printf("Roots of quadratic equation are imaginary");
}
getch();
}
{
c=a+b;
printf(" %d",c);
a=b;
b=c;
}
getch();
}
#include<math.h>
void main()
{
int i,n;
float x,sum,product,inverse_sum,mean,gm,hm;
sum=0;
product=1;
inverse_sum=0;
printf("Enter number of observations\n");
scanf("%d",&n);
printf("Enter observations\n");
for(i=1;i<=n;i++)
{
scanf("%f",&x);
sum=sum+x;
product = product*x;
inverse_sum = inverse_sum + 1/(x);
}
mean=sum/n;
gm=pow(product,1/n);
hm=n/inverse_sum;
printf("Arithmetic mean = %f\n",mean);
printf("Geometric mean = %f\n",gm);
printf("Harmonic mean = %f\n",hm);
getch();
}
void main()
{
int i,n,table;
clrscr();
printf("Enter a number \n");
scanf("%d",&n);
printf("Table of %d is\n",n);
table=1;
for(i=1;i<=10;i++)
{
table=i*n;
printf("%d\n", table);
}
getch();
}
x=x/10;
}
printf("Sum of digits = %f",s);
getch();
}
{
printf("After %3d iterations, root = %8.6f\n", itr, x1);
return 0;
}
x0=x1;
}
/* printf(" The required solution does not converge or iterations are insufficient\n");*/
return 1;
}
{
clrscr();
char string[] = "kthmcollegenashik";
char temp;
int i, j;
int n = strlen(string);
printf("String before sorting - %s \n", string);
for (i = 0; i < n-1; i++)
{
for (j = i+1; j < n; j++)
{
if (string[i] > string[j])
{
temp = string[i];
string[i] = string[j];
string[j] = temp;
}
}
}
printf("String after sorting - %s \n", string);
getch();
}