C Programming and Computer Geeks

Search MY Blog

Wednesday 27 November 2013

Find Armstrong Number between 1 to 500 using loop



Armstrong numbers are those number whose sum of the cube of all digits equal to Original number.

i.e 153= (1x1x1 + 5x5x5 + 3x3x3)

void main()
{
     int i, sum=0, cube, num=0, neen=0, a;
    
     for(i=1; i<=500; i++)
     {
          neen = i;
          num=i;
          sum=0;

          while(num!=0)
          {
              cube=0;
              a=num%10;
              num=num/10;
              cube=a*a*a;
             
              sum=sum+cube;
          }

          if(neen == sum)
          printf("\n %d is Armstrong Number",neen);
     }

     getch();
}

OutPut:

Armstrong Number
Armstrong Number


Click here for more C Faq

Tuesday 26 November 2013

Program for displaying ASCII values of English Alphabets


#include “stdio.h”

int main()
{
     int i = 0;

     for( i = 65; i <= 122; i++)
     {
          if (i >= 91 && i <= 96) //to non-alphabet characters
          continue;
          printf("%c - %d",i,i);

          printf("\t");
     }

     getch();
     return 0;
}


 
Output:

ASCII Values of English Alphabets
ASCII values of English Alphabets





 

Click here for more C Faq


Thursday 21 November 2013

Quick-sort Algorithm with Hungarian folk dance


Very good video on Quick sort Algorithm.This is the easy way to understand the Quick sort algorithm
useful video for learners/beginners in C Programming.




Concept of Quick Sort:
Quick sort is a divide and conquer algorithm. Quick sort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quick sort can then recursively sort the sub-lists.


Quick Sort algorithm
Quick Sort



The quick sort algorithm works by partitioning the array to be sorted, then recursively sorting each partition. In Partition, one of the array elements is selected as a pivot value. Values smaller than the pivot value are placed to the left of the pivot, while larger values are placed to the right.
 
See the left side placed Quick sort animation for reference.

 

Follow My YouTube Channel on LTE @ Long Term Evolution/4G

Monday 18 November 2013

My Google+ Page on C Programming Concepts

Dear Readers .. Please find my google page on C Programming and C concepts @ Google+ click on this for my Google+ page for more discussion on C Programming Concepts..

Thanks
http://www.neentech.blogspot.com

Search This Blog