c - Can someone tell me where's my mistake? My program gives the wrong output -
/*3. write programme calculate net salary 10 employees. utilize function perform next tasks: - a. read in gross salary 10 employees. b. calculate net salary each employee. c. display gross salary , net salary each employee in tabular form. example: -
gross salary net salary 2000 1820 3000 2720*/
//to calculate netsalary 10 employees , display them
#include<stdio.h> int readsalary(); int calculatenet(int); void displaysalary(int,int); int main() { int i,salary[10],netsalary[10] ; for(i=0;i<10;i++) { salary[i]=readsalary(); /*for each , every element in array, value entered*/ netsalary[i]=calculatenet(salary[i]); /*the value passed function*/ displaysalary=(salary[i],netsalary[i]); /*to display results, values frm both function passed in*/ } /*a bit confused passing in arrays in form. pls right me.*/ homecoming 0; } int readsalary() { int salary; printf("enter gross salary:"); scanf("%d",&salary); homecoming salary; } int calculatenet(int pay) { int netsalary; netsalary= pay-(pay*0.1);//formula calculate net salary homecoming netsalary; } void displaysalary(int pay_, int netsalary_) { printf("gross salary\t net salary\n"); printf("%d\t %d\n",pay_,netsalary_); }
turn warnings on:
error: lvalue required left operand of assignment
the problem trying assign value function.
change
displaysalary = (salary[i],netsalary[i]);
to
displaysalary(salary[i],netsalary[i]);
on other hand (as pointed out tim seguine) mixing integers , floats
int netsalary; netsalary= pay-(pay*0.1);//formula calculate net salary
change to
netsalary= pay-(pay/10);//formula calculate net salary
c
No comments:
Post a Comment