Saturday 22 April 2017

Example of Fibonacci Series in C

Dear Student ,

   
   Let's See , Example of Fibonacci Series with Source code with Output .



      

                                    #include<stdio.h>
                                    #include<conio.h>
                                    void main()
                                    {
                                          int num=10,a=0,b=1,c;
                                  printf("%d",a);
                                   printf("%d",b);
     
                                          while(num>=2)
                                               {
                                                      c=a+b;
                                                      printf("%d",c);
                                                       a=b;
                                                        b=c;
                                                         num--;
                                                }
                                                           getch();
                                        }

                                                 

Wednesday 19 April 2017

Example of Multiplication of two matrix in C

Dear Students ,

    Let's see your Answer with code .


#include <stdio.h>
#include<conio.h>
int main()
{
 // these are variables declared

  int row, col, row1, col1, i, j, k, sum = 0;

// These are array to store the value
  int first[5][5], second[5][5], multiply[5][5];

  printf("Enter the number of rows and columns of first matrix\n");
  scanf("%d%d", &row, &col);
  printf("Enter the elements of first matrix\n");

  for (i = 0; i < row; i++)
    for (j = 0; j < col; j++)
      scanf("%d", &first[i][j]);

  printf("Enter the number of rows and columns of second matrix\n");
  scanf("%d%d", &row1, &col1);

  if (col != row1)
    printf("Matrices with entered orders can't be multiplied with each other.\n");
  else
  {
    printf("Enter the elements of second matrix\n");

    for (i = 0; i < row1; i++)
      for (j = 0; j < col1; j++)
        scanf("%d", &second[i][j]);

    for (i = 0; i < row; i++) {
      for (j = 0; j < col1; j++) {
        for (k = 0; k < row1; k++) {
          sum = sum + first[i][k]*second[k][j];
        }

        multiply[i][j] = sum;
        sum = 0;
      }
    }

    printf("Product of entered matrices:-\n");

    for (i = 0; i < row; i++) {
      for (j = 0; j < col1; j++)
        printf("%d ", multiply[i][j]);

      printf("\n");
    }
  }
     getch();
  return 0;
}



Tuesday 18 April 2017

Example of Palindrome number in C

Dear Students ,

Q.   Do you know ? What is Palindrome number ?

Ans . If yes , then good otherwise no worry .

Let's See . What is Palindrome number .



Palindrome Numbers are those number which we could read from any side either left or right but value are same .

Example :

     num=123454321

Let's see example with program.

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

            void main()
            {
                   int num,temp,rem,sum=0;

                     printf("Enter your Number : ");
                      scanf("%d",&num);

                     temp=num;
                     while(num>0)
                      {
                             rem=num%10;
                             sum=sum*10+rem;
                             num=num/10;
                   }
                    if(sum==temp)
                      {
                         printf("Number is Palindrome ");
                        }
                      else
                          {
                            printf("Number is not Palindrome ");
                          }
                            getch();
            }


Monday 17 April 2017

A program for prime number to check whether the given number is prime or not in C

Dear Students ,

   Do you know ? 
     
Q .   What is prime Numbers ?

Ans . Prime numbers or those number which are divided by 1 or it'self . It's mean only two times .

For Example : 

    num= 7;

  if you try to divide the above number , you will get only two time reminder 0 when you divide by 1 and divide by 7 between 1 to num numbers .  


Let's Example with program : 

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
       int num , i,d=0;
         printf("Enter your Number : ");
        scanf("%d",&num);
       
        for(i=1;i<=num;i++) 
         {
             if(num%i==0)
              {
                  d++;
               }
          }
          
         if(d==2)
         {
           printf("Number is Prime ");
         }
        else
          {
            printf("Number is not Prime");
         }
  getch();
    }

  Your OutPut : 


How to write a program for Armstrong number in C .

Dear Students ,

  It's a very simple for you . First of all , we need to know that what is ARMSTRONG number .Did you know ? If yes ,"It's very Good " and if you don't know ,"No Worry ".Let's See....


    Armstrong numbers are those number which is calculate with each other of Que of Digits and Find out the total of these calculation if total equal your number .  

For Example :

  153 = 1*1*1+5*5*5+3*3*3

  153  = 153

 R.H.S=L.H.S

Example :

   #include<stdio.h>
   #include<conio.h>
   void main()
   {
     int num,rem,temp,sum=0;
     printf("Enter your Number : ");
     scanf("%d",&num);
     temp=num;
    while(num>0)
      {
         rem=num%10;
         sum=sum+rem*rem*rem;
         num=num/10;
      }

       if(temp==sum)
       {
           printf("Number is Armstrong .");
       }
       else
        {
           printf("Number is Not Armstrong ");
        }
      getch();
}


Your OutPut :