Showing posts with label Salary. Show all posts
Showing posts with label Salary. Show all posts

C Program for calculation of Gross Salary

How to write a C Program for calculation of Gross Salary in C Programming Language ?


Solution:

  1. This program takes into account the allowances of a particular candidate and then finally counts the Gross Salary.
  2. The value of the Basic Salary is entered through the keyboard.


Lara's basic salary is input through the keyboard.
Her dearness allowance is 35% of basic salary, and house rent allowance is
25% of basic salary. Write a program to calculate her gross salary.


  1. #include<stdio.h>
  2. main ()
  3. {
  4. int basic;
  5. float gross;
  6. printf("Enter your Basic Salary: ");
  7. scanf("%d", &basic);
  8. gross = basic+(0.35*basic)+(0.25*basic);
  9. printf("Your Gross Salary is: %f",gross);
  10. }

Linked List For Getting Employee Details, Display and Search For Salary C Program

How to write a C program to Linked list implementation for printing the employee details, display them and SEARCH for the salary of the employee based on his designation in C Programming Language ?



Solution:
/* Linked list implementation for printing the employee details, display them and SEARCH for the salary of the employee based on his designation */
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node* createnode(struct node*);
void display(struct node*);
void search(struct node*);

struct node
{
char name[10],des[10];
int age;
float salary;
struct node* ptr;
};

int main()
{
struct node* head;
int b,i;

head=NULL;

while(1)
{

printf("\nEnter the value\n1-> to enter the employee details\n2->to display the results\n3->to search an element\n");
scanf("%d",&b);

switch(b)
{
case (1): printf("\nEnter the number of employee details you would like to enter\n");
         scanf("%d",&i);
 while(i>0)
 {
 head=createnode(head);
 i--;
 }
 break;

case (2): display(head);
          break;

case (3): search(head);
          break;
}
}
}


void display(struct node* head)
{
if(head==NULL)
{
printf("\nThe node is yet to be displayed \n");
}

else
{
while(head!=NULL)
{
printf("\nThe name of the employee is %s\n",head->name);
printf("\nThe designation of the employee is %s\n",head->des);
printf("\nThe salary of the employee is %f\n",head->salary);
printf("\nThe age of the employee is %d\n",head->age);

head=head->ptr;

}

}
}

struct node* createnode(struct node* head)
{

struct node* newnode;
newnode=(struct node*)malloc(sizeof (struct node));

printf("\nEnter the employee name \n");
scanf("%s",newnode->name);
printf("\nEnter the employee's designation \n");
scanf("%s",newnode->des);
printf("\nEnter the salary of the employee \n");
scanf("%f",&newnode->salary);
printf("\nEnter the age of the employee\n");
scanf("%d",&newnode->age);

if(newnode == NULL)
{
printf("\n Enter the newnode \n");
newnode->ptr=NULL;
}

else
{
newnode->ptr=head;

}
return newnode;
}


void search(struct node* head)
{
char ch[10];

printf("\nEnter the search string\n");

scanf("%s",ch);


while(head!=NULL)
{
if(strcmp(ch,head->des)==0)
{
printf("\nThe element is matched\n");
printf("\nThe salary of the designated member is %f\n",head->salary);

}

else {
printf("\nThe element is not matched\n");
}
head=head->ptr;
}
}