WELCOME

Welcome to KoDes4U

Pages

Thursday, March 3, 2011

Even Number printig Code(C program)

/*Write a program to find the even numbers from 1 to 100
Coded for KoDes4U.blogspot.com*/
#include
#include
int main()
{
int i;
clrscr();
printf("Even numbers from 1 to 20\n");
for(i=1;i<=20;i++)
{
if(i%2==0)
printf("%d\n",i);
}
getch();
return 0;
}

Use of math.h library functions(C program)

/*Write a program to find cosine of 0 to 180 degree.
Coded for KoDes4U.blogspot.com*/
#include
#include
#include
int main()
{
int degree;
float pi=3.14,x,y;
clrscr();
printf("Degree\tCosine\n");
for(degree=0;degree<=180;degree=degree+10)
{
x=(pi/180)*degree;
y=cos(x);
printf("%d\t%f",degree,y);
printf("\n");
}
getch();
return(0);
}

Quadratic Equation Code(C program)

/*Write a program to find a quadratic equation ax2+bx+c=0.

Coded for KoDes4U.blogspot.com*/

#include

#include

#include

void main()

{

int a,b,c,disc;

float alpha,beta;

clrscr();

printf("\nEnter the value of a,b and c:");

scanf("%d%d%d",&a,&b,&c);

disc=(b*b)-(4*a*c);

if(disc<0)

printf("\nRoots are imaginary.");

else

{

alpha=(-b+sqrt(disc))/(2*a);

beta=(-b-sqrt(disc))/(2*a);

printf("\n1st Root=%f\t2nd Root=%f",alpha,beta);

}

getch();

}