C program to find the value of sin(x)

Write a C program to find the value of sin(x) using the series up to the given accuracy (without using user defined function) Also print sin(x) using library function. Read more about C Programming Language.

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                                  Happy Coding
***********************************************************/


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

void main()
{
 int n, x1;
 float  acc, term, den, x, sinx=0, sinval;

 clrscr();

 printf("Enter the value of x (in degrees)n");
 scanf("%f",&x);

 x1 = x;

 /* Converting degrees to radians*/

 x = x*(3.142/180.0);
 sinval = sin(x);

 printf("Enter the accuary for the resultn");
 scanf("%f", &acc);

 term = x;
 sinx = term;
 n = 1;

 do
 {
  den = 2*n*(2*n+1);
  term = -term * x * x / den;
  sinx = sinx + term;
  n = n + 1;

 } while(acc <= fabs(sinval - sinx));

 printf("Sum of the sine series         = %fn", sinx);
 printf("Using Library function sin(%d) = %fn", x1,sin(x));

}         /*End of main() */
Read more Similar C Programs
C Basic

Search Algorithms.

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the GCD and LCM of two integers

Write a C program to find the GCD and LCM of two integers output the results along with the given integers. Use Euclids’ algorithm to find the GCD and LCM.
Euclids’ algorithm uses the division algorithm which repeatedly divides starting from the two numbers we want to find the GCD of until we get a remainder of 0. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                                  Happy Coding
***********************************************************/

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

void main()
{
 int  num1, num2, gcd, lcm, remainder, numerator, denominator;
 clrscr();

 printf("Enter two numbersn");
 scanf("%d %d", &num1,&num2);

 if (num1 > num2)
 {
  numerator = num1;
  denominator = num2;
 }
 else
 {
  numerator = num2;
  denominator = num1;
 }
 remainder = num1 % num2;
 while(remainder !=0)
 {
  numerator   = denominator;
  denominator = remainder;
  remainder   = numerator % denominator;
 }
 gcd = denominator;
 lcm = num1 * num2 / gcd;
 printf("GCD of %d and %d = %d n", num1,num2,gcd);
 printf("LCM of %d and %d = %d n", num1,num2,lcm);
}  /* End of main() */
Read more Similar C Programs

Data Structures

C Sorting

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the sum of ‘N’ natural numbers.

Write a C program to find the sum of ‘N’ natural numbers. Natural numbers are the whole numbers except zero, usually we used for counting.
Example:1, 2, 3, 4,———– Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



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

void main()
{
int i, N, sum = 0;

clrscr();

printf("Enter an integer numbern");
scanf ("%d", &N);

for (i=1; i <= N; i++)
{
sum = sum + i;
}

printf ("Sum of first %d natural numbers = %dn", N, sum);
}
Read more Similar C Programs
Searching in C

Number Theory 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to check whether a given integer number is positive or negative.

Write a C program to check whether a given integer number is positive or negative.Read more about C Programming Language . This program is available on GitHub https://github.com/snadahalli/cprograms/blob/master/posneg.c

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

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

void main()
{
int number;
clrscr();

printf("Enter a numbern");
scanf ("%d", &number);

if (number > 0)
printf ("%d is a positive numbern", number);
else if (number < 0)
printf ("%d is a negative numbern", number);
else
printf("You entered 0n");

}
Read more Similar C Programs
Searching in C

Number Theory 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

–>

(c) www.c-program-example.com

C program to check whether a given integer is odd or even.

Write a C program to check whether a given integer is odd or even.Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



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

void main()
{
int ival, remainder;

clrscr();

printf("Enter an integer :");
scanf ("%d", &ival);

remainder = ival % 2;

if (remainder == 0)
printf ("%d, is an even integern", ival);
else
printf ("%d, is an odd integern", ival);

}
Read more Similar C Programs
Searching in C

Number Theory 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the simple interest , given principle, rate of interest and time.

C program to find the simple interest , given principle, rate of interest and time. Simple Interest is the money paid by the borrower to the lender, based on the principle amount, Interest rate and the time period.
Simple interest is calculated by, SI=P*T*R/100 formula.
Where, P is the principle amount.
T is the time period.
R is the Interest Rate.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



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

void main()
{

float p, r, si;
int t;

clrscr();

printf("Enter the values of p,r and tn");
scanf ("%f %f %d", &p, &r, &t);

si = (p * r * t)/ 100.0;

printf ("Amount = Rs. %5.2fn", p);
printf ("Rate = Rs. %5.2f%n", r);
printf ("Time = %d yearsn", t);
printf ("Simple interest = %5.2fn", si);

}
Read more Similar C Programs
Searching in C

Number Theory 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the area of a circle, given the radius

C program to find the area of a circle, given the radius. This is the simple C program to find the area of the circle, Here we define the PI value as macros, because it is constant through out the program. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <conio.h>
#include <math.h>
#define PI 3.142

void main()
{
float radius, area;
clrscr();

printf("Enter the radius of a circlen");
scanf ("%f", &radius);

area = PI * pow (radius,2);

printf ("Area of a circle = %5.2fn", area);
}
Read more Similar C Programs
Searching in C

Number Theory 
 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program To Swap Two Variables

C Program To Swap Two Variables without using the third variable. This type of C programs are asked in various Interviews.There are various methods to achieve this one. For example, a=a+b;
b=a-b;
a=a-b;
Here we use the XOR(^) operator to Swap Two Variables without using the third variable. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include<stdio.h>

int main()
{
int a=20;
int b=10;
printf("Values of a and b before swappingn");
printf("a=%dnb=%dn",a,b);
a=a^b;
b=b^a;
a=b^a;
printf("Values of a and b After swappingn");
printf("a=%dnb=%dn",a,b);
return 0;
}
Read more Similar C Programs
C Interview Questions

Number Theory 
C Strings
 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to find the number and sum of all integers from 100 to 200 which is divisible by 7

Example programs to solve the problems of Arrays in C.
C program to find the number and sum of all integers from 100to 200 which is divisible by 7. Read more about C Programming Language .

Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to read ten integers from the keyboards and print the sum of even and odd numbers.

Example programs to solve the problems of Arrays in C.
C Program to read ten integers from the keyboard and print the sum of even and odd numbers.Read more about C Programming Language .

Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com