Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Parallel Processing ProgramsRSS Feeds

Program to Raise a 15% Salary to Employee Working In a Company

Posted By: Zoe Hughes     Category: C Programming     Views: 3001

Program to Raise a 15% Salary to Employee Working In a Company.

Code for Program to Raise a 15% Salary to Employee Working In a Company in C Programming

#include<stdio.h>
#include<pthread.h>

struct emp
{
    char name[10];
    int salary;
    int no;
}*t;
int nthread,n;
void *work(void *);
main()
{
    pthread_t id;
    struct emp e[5];
    int i;
    
    printf("Enter The No Of Thread");
    scanf("%d",&nthread);
    
    printf("Enter The No of Element");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("Enter the Employee Name :  ");
        scanf("%s",&e[i].name);
        printf("Enter the Employee Salary : ");
        scanf("%d",&e[i].salary);
    }
    
    /*for(i=0;i<n;i++)
{
printf("%s",e[i].name);
printf("%d\n",e[i].salary);
}*/
for(i=0;i<nthread;i++) { e[0].no=i; if(0==pthread_create(&id,NULL,work,(void *)&e)) { continue; } else { printf("Problem In Thread Creation"); } } pthread_join(id,NULL); printf("\n\nAfter Updation\n"); printf("E_Name\tE_salary\n"); for(i=0;i<n;i++) { printf("%s\t",e[i].name); printf("%d\n",e[i].salary); } } void *work(void *e) { int j,i; t=(struct emp *)e; // printf("%d",t[0].no); for(j=t[0].no;j<n;j+=nthread) { t[j].salary=t[j].salary+(t[j].salary*0.15); } pthread_exit(NULL); } /* OUTPUT:
---------
Enter The No Of Thread2
Enter The No of Element6
Enter the Employee Name : rohit
Enter the Employee Salary : 5000
Enter the Employee Name : rakesh
Enter the Employee Salary : 6000
Enter the Employee Name : amit
Enter the Employee Salary : 8000
Enter the Employee Name : amir
Enter the Employee Salary : 9000
Enter the Employee Name : govinda
Enter the Employee Salary : 6000
Enter the Employee Name : ram
Enter the Employee Salary : 80000


After Updation
E_Name E_salary
rohit 5749
rakesh 6899
amit 9199
amir 10349
govinda 6899
ram 91999
*/
  
Share: 



Zoe Hughes
Zoe Hughes author of Program to Raise a 15% Salary to Employee Working In a Company is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!