Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows
Showing posts with label Loops (C). Show all posts
Showing posts with label Loops (C). Show all posts

Sunday, January 9, 2011

Write a program to find out the first 25 numbers of a Fibonacci sequence. Following are the first few terms of the Fibonacci Sequence: 1 1 2 3 5 8 13 21 34 55 89…………………


Source Code :

#include<stdio.h>
void main()
{
      float a=1,b=1,c;
      int ctr=3;

Write a program to print all Armstrong numbers between 1 & 500. If the sum of cubes of each digit of the no. is equal to the no. itself, then the no. is called an Armstrong Number.


Source Code :

#include<stdio.h>
void main()
{
      int b,c=0,div,rem,i,j,n,ctr=0,temp[5];
      clrscr();
      printf("\nArmstrong Numbers between 1 to 500 : ");
      for(n=1;n<=500;n++)
      {
            div=n;

If a 5-digit number is input through the keyboard. Write a program to print a new number by adding one to each of its digits. E.g. If the no. that is 12391, then the output should be displayed as 23402.


Source Code :

#include<stdio.h>
void main()
{
      int m,i,j,n,r=0,c;
      clrscr();
      printf("Enter a 5-digit number : ");
      scanf("%d",&m);

If a 4-digit number is input though the keyboard. Write a program to obtain the sum of the first & last digit of this number.


Source Code :

#include<stdio.h>
void main()
{
      int a,sum=0,rem,div,ctr=1;
      clrscr();
      printf("\nEnter a 4-digit Number : ");
      scanf("%d",&a);

Tuesday, January 4, 2011

Write a C Program to generate Prime Number from 10 to 50


Source Code :

#include<stdio.h>
void main()
{
      int n=10,i,j,fl=0;            //Declaration of variables
      clrscr();
      printf("\nThe Prime Numbers between 10 to 50 :")
      for(i=n;i<=50;i++)      //For Loop Iteration from 10 to 50 times
      {

Write a Program to find out the Greatest Common Divisor (GCD) of Two Numbers

Source Code :

#include<stdio.h>
void main()
{
      int a,b,i,s,cf=0;
      clrscr();
      printf("\nEnter Two Numbers : ");
      scanf("%d%d",&a,&b);
      if(a<b)
            s=a;        //Assigning smallest number
      else
            s=b;

Write a C Program to check whether a number is Prime or not

Source Code :

#include<stdio.h>
void main()
{
      int n,i,fl=0;     //Declaration of variables
      clrscr();
      printf("\nEnter a Number : ");
      scanf("%d",&n);   //Initialization of number from user
      for(i=2;i<n;i++)    //For Loop for checking prime number
      {
            if(n%i==0)  //Checking if the number can be divided
            {                        //by any other number other
                  fl=1;
            }
      }