Thank you all for being with us.
Learn, Create and Implement.

  • Build Concept

    You can build your concept in programming on programsway.com.

  • Examples

    There are many C Programming examples on programsway.com.

  • Ask Questions

    Ask questions and get quick answers. Request any program and we will publish that program.

  • Sunday 5 January 2014

    Here in this post we represent two basic C programming examples. Those example are only for the beginners.
    v  Check whether a number is palindrome or not through C program.
    v  Check whether a number is prime or not through C program.
    Now the answers are given below:
    Answer of no 1:
    A number is said to be palindrome if the reverse of that number is same as the original number. Coding is given below…
    /* C program to check whether a number is palindrome or not */
    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
       int n,t,rev=0;
      printf("Give the value of of the number\n");
      scanf("%d",&n);
      t=n;
      while(t!=0)
      {
        rev=rev*10;
        rev=rev+t%10;
       t=t/10;
     }
    if(rev!=n)
    printf("the entered number is not a palindrome\n");
    else
    printf("the entered number is palindrome number\n\n");                          
    }
    Answer of no 2:
    A number is said to be prime if that number is only divisible by 1 and the number itself. Coding is given below…


    /* C program to check whether a number is prime or not*/

    #include<stdio.h>
    int main()

    {

    int a,c=0,i,num;

    printf("Give the value of num\n");

    scanf("%d",&num);

    for(i=1;i<=num;i++)

    {

    a=num%i;

    if(a==0)

    {

    c=c+1;

    }

    }

    if(c==2)

    printf("num is prime number");

    else

    printf("num is not a prime number");




    }

    0 comments:

    Post a Comment