Welcome To Uday Satya Blog

31 - 35 PROGRAMS



                                                                                                                                       
/* ******************************************
            31. To Find Gross Salary of A Worker
    ***************************************** */

   #include<*stdio.h>
   #include<*conio.h>
   void main()
    {
    float bs,hra,da,gs;
    clrscr();
    printf("\n Enter Basic Salary : Rs. ");
    scanf("%f", &bs);
    if(bs<1500)
        {
        hra = bs * 10 /100;
        da = bs * 90 / 100;
        }
    else
        {
        hra = 500;
        da = bs * 98 / 100;
        }
    gs = bs + hra + da;
    printf("\n\n Gross Salary is : Rs. %f", gs);
    getch();
    }

   Output :

   Enter Basic Salary : Rs. 500

   Gross Salary is : Rs. 1000
                                                                                                                                              
/* ********************************************
                   32. To Print 1-10 using While loop
    ******************************************** */

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

   void main()
    {
    int i = 1;
    clrscr();
    while(i <= 10)
        printf("\n %d \n", i++);
    getch();
    }

   Output :

   1
   2
   3
   4
   5
   6
   7
   8
   9
   10
                                                                                                                                              
/* *********************************************
            33. To Find Sum of Digits of a Give Number
    ********************************************* */

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


   void main()
    {
    int n,s = 0,r,x;
    clrscr();
    printf("\n Enter any Number,To Find Sum of Digits : ");
    scanf("%d", &n);
    x = n;
    while(x > 0)
        {
        r = x % 10;
        s = s + r;
        x = x / 10;
        }
    printf("\n\n Sum of Digits of %d is : %d", n, s);
    getch();
    }

   Output :
 
   Enter any Number,To Find Sum of Digits : 45

   Sum of Digits of 45 is : 9
                                                                                                                                            
/* **************************************************
      34. To Check Whether a Number is an Armstrong or not
    ************************************************* */

   #include<*stdio.h>
   #include<*conio.h>
   void main()
    {
    int n,s = 0,r,x;
    clrscr();
    printf("\n Enter any Number,To Check for Armstrong or not : ");
    scanf("%d", &n);
    x = n;
    while(x > 0)
        {
        r = x % 10;
        s = s + r*r*r;
        x = x / 10;
        }
    if(s == n)
        printf("\n\n %d is an Armstrong Number", n);
    else
        printf("\n\n %d is not an Armstrong Number", n);
    getch();
    }

   Output :

   Enter any Number,To Check for Armstrong or not : 153

   153 is an Armstrong Number
                                                                                                                                                  
/* **********************************************
   35. To Check Whether a Number is Pallindrome or not
    ********************************************** */

   #include<*stdio.h>
   #include<*conio.h>
   void main()
    {
    int n,s = 0,r,x;
    clrscr();
    printf("\n Enter any Number,To Check for Pallindrome : ");
    scanf("%d", &n);
    x = n;
    while(x > 0)
        {
        r = x % 10;
        s = s * 10 + r;
        x = x / 10;
        }
    if(s == n)
        printf("\n\n %d is a Pallindrome Number", n);
    else
        printf("\n\n %d is not a Pallindrome Number", n);
    getch();
    }

   Output :
   Enter any Number,To Check for Pallindrome : 121
   121 is a Pallindrome Number
  

0 comments:

Post a Comment