Showing posts with label formulae. Show all posts
Showing posts with label formulae. Show all posts

February 4, 2011

C Program for to find Prime Number

A Prime Number (or a prime) is a natural number that has exactly two distinct natural number divisors: 1 and itself.

The prime numbers under 100:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

C Program for Fibonacci Series

Fibonacci number
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34,55,89,144,......



A Fibonacci spiral created by drawing arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes
By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

C Program to Calculate Factorial of a Number


In mathematics, the factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n.

For example, 5 ! = 5 * 4* 3 * 2* 1 = 120

Using While Loop

Method  1:

//C Program to Calculate Factorial of a Number
#include<stdio.h>
#include<conio.h>
void main()
{
int n,fact=1;
clrscr();
printf("Enter any Number:\n\n");
scanf("%d",&n);
while(n>1)
{
fact=fact*n;
n--;
}
printf("\nFactorial is=%d",fact);
getch();
}


C Program Calculate Simple Interest for 3 sets of p, n & r

Using while loop


/*C Program Calculate Simple Interest for 3 sets of p, n & r
p, n & r represent principle, no. of years & rate of interest*/
#include<stdio.h>
#include<conio.h>
void main()
{
int p,n,count=1;
float r,si;
clrscr();
while(count<=3)
{
printf("Enter value for p,n & r\n\n");
scanf("%d%d%f",&p,&n,&r);
si=(p*n*r)/100;
printf("\nSimple Interest =%f",si);
count++;
}
getch();
}

C Program for Calculate Simple Interest


//C Program for Calculate Simple Interest
#include<stdio.h>
#include<conio.h>
void main()
{
float p,r,n,si;
clrscr();
printf("\nEnter the profit, rate & no of yr\n\n ");
scanf("%f%f%f",&p,&r,&n);
si=(p*r*n)/100;
printf("\nSimple Intrest=%f",si);
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

C Program for degree Celsius to degree Fahrenheit


//C Program for degree Celsius to degree Fahrenheit
#include<stdio.h>
#include<conio.h>
void main()
{
float c,p;
clrscr();
printf("\nCelsius");
scanf("%f",&c);
p=(c*9/5)+32;
printf("\nFahrenheit=%f",p);
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

C Program for Average of 4 Number


//C Program for Average of 4 Number
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,c,d,avg;
clrscr();
printf("\nEnter the 4 nos.");
scanf("%f%f%f%f",&a,&b,&c,&d);
avg=(a+b+c+d)/4;
printf("Averageis=%f",avg);
getch();
}

Hope you liked my posts, give comments if you have any doubts.. :)

C Program for Area & the Circumference of circle


//Area & the Circumference of circle
#include<stdio.h>
#include<conio.h>
void main()
{
int r, p=3.14;
float cir,area;
clrscr();
printf("\nEnter the radius of the circle");
scanf("%d",&r);
cir=2*p*r;
area=p*r*r;
printf("\nThe Circumference of the circle is=%f",cir);
printf("\nThe area of the circle is=%f",area);
getch();
}
Hope you liked my posts, give comments if you have any doubts.. :)

C Program for Area & perimeter of Rectangle


//Area & perimeter of Rectangle
#include<stdio.h>
#include<conio.h>
void main()
{
float length,breadth,aor,por;
clrscr();
printf("\nEnter the Length & Breadth of Rectangle");
scanf("%f%f",&length,&breadth);
aor=length*breadth;
por=2*(length+breadth);
printf("\nThe area of Rectangle=%f",aor);
printf("\nThe perimeter of Rectangle=%f",por);
getch();
}
Hope you liked my posts, give comments if you have any doubts.. :)

Twitter Delicious Facebook Digg Stumbleupon Favorites More