You Are The Visitor Number

Sunday, March 16, 2008

/* Program to evaluate the expression (ax+b)/(ax-b) */

This Program Evaluates the expression (ax+b)/(ax-b) . As this program uses the Associativity of operators , an important topic while using so many arithmetic operators in an equation. So note this ….. Also this program uses division , obviously you have to be careful about choosing integer or float . Especially while considering the output. You take these variables as integer & see what happens??!!


 

/* Program to Evaluate the expression (ax+b)/(ax-b) */

/* Author Mitochondria Technologies Inc. (Regd.)*/

#include<stdio.h>

#include<conio.h>

void main()

{

float a,b,x,sum;

clrscr();

printf("Enter the values of a,b & x : ");

scanf("%f%f%f",&a,&b,&x);

sum=((a*x+b)/(a*x-b));

printf("The Result of the Expression is : %f",sum);

getch();

}

Friday, March 14, 2008

/* Program to evaluate sum of series S=1+1/2+1/3...+1/N */

I think in this case no introduction is required. I have taken output as float because naturally it will be float. Taking output as int the program will work but don't give accurate answers.

/* Program to evaluate sum of series S=1+1/2+1/3...+1/N */

/* Author Mitochondria Technologies Inc. */

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n;

float sum;

clrscr();

printf("\n Enter the value to N : ");

scanf("%d",&n);

sum=0;

for(i=1;i<=n;i++)

sum=sum+1.0/i;

printf("\n Sum of series : %f",sum);

getch();

}

Thursday, March 13, 2008

/* Program to find Largest of three numbers */

This Program will tell you which number the largest of all the three number you have entered. For example you have entered 16, 25, 41 obviously it will tell 41 as largest of all. Programs are created with utmost care. User may check the logic error if any please report me immediately as a comment on this web page. Remember C is not for fear it's for Enjoy Dear!!!!

/* Program to find Largest of three nos. */

/* Author Mitochondria Technologies Inc. */

#include<stdio.h>

#include<conio.h>

void main()

{

int x,y,z,large;

clrscr();

printf("Enter three numbers : ");

scanf("%d%d%d",&x,&y,&z);

large=x;

if (y>large)

large=y;

if (z>large)

large=z;

printf("The Biggest no. is :%d",large);

getch();

}


 

/* Program to Calculate Factorial of a No. */

Here is Program which calculates Factorial of a number. For Example 4! =24, 5! =120. See again I have used FOR loop in this program you can also try it with while also to widen your horizons. But soon you realize that FOR loop is the shortest, finest method of programming. Enjoy Programming!!!!!!

/* Program to Calculate Factorial of a Number */

/* Author Mitochondria Technologies Inc. */

#include<stdio.h>

#include<conio.h>

void main()

{

int num,i=1,facto=1;

clrscr();

printf("\n Enter The Number : ");

scanf("%d",&num);

facto=1;

for(i=1;i<=num;i++)

{

facto=i*facto;

}

printf("\n The Factorial of the number entered is : %d",facto);

getch();

}

Saturday, March 8, 2008

/* Program to Create a Fibonacci Series */

This is a simple Program in C language you can Generate
Fibonacci Series From
this Program I have made this program Using While Loop Scratch your mind & you can also try it with For & do while loop. Fibonacci series starts with 0 & 1 & precede with the addition of last two terms ie net term will be 0+1 i.e. 1 & next 1+1=2 Then next 2+1=3 so series becomes 0,1,1,2,3,5,8,13,21,34,65……so on

/* Program to Create a Fibonacci Series */

/* Author Mitochondria Technologies Inc. */

#include<stdio.h>

#include<conio.h> /*Header Files */

void main() /*Main function to begin program & it is kept empty*/

{

int a,b,c,count=0,n; /*variable declaration & also initialization counter in one statement*/

clrscr(); /*clear screen to clear outputs after usage*/

printf("Enter The Value of No. : "); /*Input command for user for length of series*/

scanf("%d",&n); /*Taking input*/

a=0,b=1;

printf("%d\n",a);

printf("%d\n",b);

while(count<n-2) /*condition counter*/

{

c=a+b; /*series generating logic*/

printf("%d\n",c);

a=b;

b=c;

count++; /*increment counter*/

}

getch(); /*getch function to retain output on screen*/

}