Welcome To Uday Satya Blog

26 - 30 PROGRAMS



                                                                                                                                          
/* ****************************************
         26. To Find Greatest Among Two Numbers
    **************************************** */

   

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


   void main()
    {
    int a,b;
    clrscr();
    printf("\n Enter any Two Numbers to Find Greatest Among Both : ");
    scanf("%d %d", &a, &b);
    if(a>b)
        printf("\n\n %d is Greatest Among Both", a);
    else
        printf("\n\n %d is Greatest Among Both", b);
    getch();
    }

   Output :

   Enter any Two Numbers to Find Greatest Among Both : 5 6

   6 is Greatest Among Both
                                                                                                                                                           
   /* ******************************************
         27. To Find Greatest Among Three Numbers
    ******************************************* */

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


   void main()
    {
    int a,b,c;
    clrscr();
    printf("\n Enter any Three Numbers,To find Greatest among them : ");
    scanf("%d %d %d", &a, &b, &c);
    if(a>b && a>c)
        printf("\n\n %d is Greatest among Those Three Numbers", a);
    else
        if(b>c)
            printf("\n\n %d is Greatest among Those Three Numbers", b);
        else
            printf("\n\n %d is Greatest among Those Three Numbers", c);
    getch();
    }

   Output :

   Enter any Three numbers,To Find Greatest among them : 4 5 6
 
   6 is Greatest among Those Three Numbers 
                                                                                                                                                 
/* ********************************************
            28. To Check if a Year is Leap year or not
    ******************************************** */

   #include<*stdio.h>
   #include<*conio.h>
   void main()
    {
    int n;
    clrscr();
    printf("\n Enter any Year,To Check for Leap Year : ");
    scanf("%d", &n);
    if(n % 4 == 0)
        printf("\n\n %d is a Leap Year", n);
    else
        printf("\n\n %d is not a Leap Year", n);
    getch();
    }

   Output :

   Enter any Year,To Check for Leap Year : 2008

   2008 is a Leap Year
                                                                                                                                                 
/* *********************************************
      29. To Check if a Number is Perfect Square or not
    ******************************************* */

   #include<*stdio.h>
   #include<*conio.h>
   #include
   void main()
    {
    int n,x;
    clrscr();
    printf("\n Enter any Number,To Check for a Perfect Square or not : ");
    scanf("%d", &n);
    x = sqrt(n);
    if(x * x == n)
        printf("\n\n %d is a Perfect Square", n);
    else
        printf("\n\n %d is not a Perfect Square", n);
    getch();
    }

   Output :
 
   Enter any Number,To Check for a Perfect Square or not : 36

   36 is a Perfect Square
                                                                                                                                         
/* ************************************************
       30. To Check Whether Given Number is Even or odd
    ********************************************** */

   #include<*stdio.h>
   #include<*conio.h>
   void main()
    {
    int a;
    clrscr();
    printf("\n Enter any Number,To Check for an Even or odd : ");
    scanf("%d", &a);
    if(a % 2 == 0)
        printf("\n\n %d is an Even Number", a);
    else
        printf("\n\n %d is an odd Number", a);
    getch();
    }

   Output :

   Enter any Number,To Check for an Even or odd : 6

   6 is an Even Number


0 comments:

Post a Comment