Monday, December 12, 2016

Sample C program

Basic salary of employee is input through the keyboard. DA is 40% of basic salary & house rent allowance (HRA) is 20% of the basic salary. Calculate his gross salary?

Action()
{
    
    float basic,da,hra,gross;
   
    basic=10000;
   
    da= basic*0.2;
    hra=basic*0.4;
    gross= basic+da+hra;
   
    lr_output_message("The gross value is %f",gross);
   
    return 0;
}

2) Temperature of a city is Fahrenheit degrees is input to keyboard write a program to convert this temperature into centigrade  [TC = (TF-32)*5/9] 


Action()
{
    
    float f,c;
   
    f=100;
   
    c=(f-32)*5/9;
   
    lr_output_message("The temparature is %f",c);
   
    return 0;
}


3) The length and breadth of the rectangle & radius of the circle are input through key board. Write a program to calculate the area, perimeter & the circumference of the circle.


Action()
{
    
  float l,b,r,area,perimeter,circumference;
 
 
  l=100;
  b=100;
  r=100;
 
  area=l*b;
 
  perimeter=2*(l+b);
 
  circumference=2*3.14*r;
 
 
  lr_output_message("The area value %f",area);
 
  lr_output_message("The perimeter value %f",perimeter);
 
  lr_output_message("The circumference value %f",circumference);
   
  return 0;
}



4) Two numbers are input through keyboard into two locations C & D. Write
a program to interchange the content of C & D.



Action()
{
   
int a,b,c;

= 50;
= 60;

= a;
= b;
= c;


lr_output_message("The value of %d,%d",a,b);
       
    return 0;
}


 

No comments:

Post a Comment