Electrofriends

C program to calculate the GCD of a number

by Ranjith | April 4th, 2010.

Write a program to calculate the Greatest Common Divisor(GCD) of a number #include<stdio.h> #include<conio.h> #include<process.h> int gcd(int m,int n) { int rem; while(n!=0) { rem=m%n; m=n; n=rem; } return(m); } main() { int num1,num2,num3,gcd1,gcd2; clrscr(); printf("Enter three positive integers"); scanf("%d%d%d",&num1,&num2,&num3); if(num1==0 && num2==0 && num3==0) { printf("\n Invalid number"); exit(0); } gcd1=gcd(num1,num2); gcd2=gcd(num3,gcd1); printf("\n GCD [...]

Read More..

C program for finding remainder

by Ranjith | September 20th, 2009.

OUTPUT:
enter frame:
1 0 1 1 0 1 0 0
enter generator:
1 0 1 0
remainder is:
0 0 1 0

Read More..

To find the sum of the cos series

by Ranjith | December 4th, 2008.

Here is the program to find the Cosine of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no sophisticated functions but a simple while loop and other math functions. Logic: The program follows the mathematical cosine series, where cosine of the entered radian angle ? [...]

Read More..

Program to find the sum of the sine series

by Ranjith | December 4th, 2008.

Here is the program to find the Sinusoidal value of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no built in functions but a simple while loop and other math functions. Logic: The program follows the mathematical sine series, where cosine of the entered radian [...]

Read More..

To find the sum of digits

by Ranjith | December 4th, 2008.

Here is the program to find the sum of the digits of the entered number. Main idea in this program is to slice down the given number into digits and to operate on them. Logic : The program asks the user to enter the number, to find out the sum of its digits. Sets the [...]

Read More..

To check whether a given number is palindrome or not

by Ranjith | December 4th, 2008.

This is the program to check for the ‘Palindrome’ property of the given number. Palindrome is the instinct property of any literal segment, where the segment reads the same either from left to right or vice versa. For example : 12321 and  LEVEL  are the palindromes as they reads same if we go from right [...]

Read More..

To reverse a given number

by Ranjith | December 4th, 2008.

Here is the program to mathematically reverse the entered integer. The program uses simple library functions, and an easy flow. Logic :  The main idea here is to trace the entered number till its length, and slicing up in each of the iterations. The program asks the user to enter the number to reverse. Sets [...]

Read More..

Program for Armstrong numbers

by Ranjith | December 4th, 2008.

Here is the program to calculate the Armstrong numbers, which will fall within the limit, starting from zero. The program expects the user to enter the upper limit. Definition : Armstrong numbers are the integer numbers , where -the sum of third  power of each digits – equals to the given number itself. Logic :  [...]

Read More..

Program to find the prime numbers between a given range

by Ranjith | December 4th, 2008.

The program is to find all the prime numbers falls inside the user defined range. A prime number is a one, whose divisors are 1 and the number itself. Logic: This is advanced version of the previous program. Here, user need to enter two numbers as the lower and upper limits for the iteration loop [...]

Read More..

Program to find the prime numbers below a given number.

by Ranjith | December 4th, 2008.

The program is to find all the prime numbers in the range, which starts from zero and ends at user defined limit. A prime number is a one, whose divisors are 1 and the number itself. Logic: This is a slightly modified version of the previous program. Here, user need to enter the number as [...]

Read More..

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya