please write the programe in c language for this
Accept 5 Employee details to find highest salary employe name using for loop and arrays
Thanks in advance
6 27982
please write the programe in c language for this
Accept 5 Employee details to find highest salary employe name using for loop and arrays
Thanks in advance
The experts on this site are more than happy to help you with your problem but we cannot do your assignment for you. Attempt the assignment yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.
- #include <stdio.h>
-
main()
-
{
-
char employeeName[5][20],employeeSalary[5];
-
int i;
-
int maxSalary=0, maxEmpl=-1;
-
for(i=0;i<5;i++)
-
{
-
printf("Enter details of employee no. %d :",i+1);
-
scanf("%s",employeeName[i];
-
scanf("%d",&employeeSalary[i]);
-
if(employeeSalary[i]>maxSalary)
-
{
-
maxSalary=employeeSalary[i];
-
maxEmpl=i;
-
}
-
}
-
printf("Employee %s has the max salary %d", employeeName[maxEmpl],employeeSalary[maxEmpl]);
-
}
you had a missing ) but otherwise the program is OK -
#include <stdio.h>
-
main()
-
{
-
char employeeName[5][20],employeeSalary[5];
-
int i;
-
int maxSalary=0, maxEmpl=-1;
-
for(i=0;i<5;i++)
-
{
-
printf("Enter details of employee no. %d :",i+1);
-
scanf("%s",employeeName[i]); // ** missing )
-
scanf("%d",&employeeSalary[i]);
-
if(employeeSalary[i]>maxSalary)
-
{
-
maxSalary=employeeSalary[i];
-
maxEmpl=i;
-
}
-
}
-
printf("Employee %s has the max salary %d", employeeName[maxEmpl],employeeSalary[maxEmpl]);
-
}
-
it is a good idea to indent the code as it make the overall structure clearer
While comparing you are trying to compare the Char with an int (i.e Salary)...
as a beginner try to study the multidimensional array of strings and then try to implement it where at that time also you have to convert that salary into an integer by using atoi then only you can compare it...
Better see the below program will help you which is taken only a integer that to single dimensional array....
Note: you have to enter the Emp no as a integer..
Example
Emp no is 6695 or 66785 like thatnot excedding 32767
and salary can exceed see the datatype.... - #include <stdio.h>
-
#include <conio.h>
-
int main()
-
{
-
int emp[10]
-
unsigned int sal[10];
-
int i,j=0,
-
unsigned int max=0;
-
clrscr();
-
for(i=0;i<3;i++)
-
{
-
printf("Enter the Emp No: ");
-
scanf("%d",&emp[i]);
-
printf("Enter the Salary: ");
-
scanf("%u",&sal[i]);
-
if(sal[i]>max)
-
{
-
j=i;
-
}
-
}
-
printf("The Highest salry person is %d and his salary is %u",emp[j],sal[j]);
-
getch();
-
return 0;
-
}
why you have used k=-1?i mean why -1?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Justin Emlay |
last post by:
I'm hopping someone can help me out on a payroll project I need to
implement.
To start we are dealing with payroll periods. So we are dealing with an
exact 10 days (Monday - Friday, 2 weeks).
...
|
by: satish |
last post by:
create table employee(empid int,empname varchar(20),managerid int not
null, sal int)
insert into employee values(1,'ranga',22,5000)
insert into employee values(2,'satish',22,8000)
insert into...
|
by: sallyk57 |
last post by:
Help with following Programs:
Write two programs one where the performance rating here shoud be entered as a int where Excellent =1, Good= 2, Poor=3. an employee who is rated excellent will...
|
by: ranjitkumar |
last post by:
Hi everybody,
create table employee
{
empno char(5) primay key,
name varchar2(30),
salary number(5,2)
};
1. For the above table how to find the employee with the third highest...
|
by: partha das |
last post by:
sir
i need a single sql query it may be sub query need to retrive the 5th highest salary from a employee table
|
by: hmmtn |
last post by:
I would appreciate any help on this one. Assignment is as
follows: Develop a program that will determine the gross pay for each
of several employees. The company pays "straight time" for the first...
|
by: uwcssa |
last post by:
I try to drop a table as:
I got: During SQL processing it returned:
SQL0478N The object type "TABLE" cannot be dropped because there is
an object "sch.SQL070515104729271", of type "FUNCTION",...
|
by: SMH |
last post by:
Hi All,
I am currently learning .Net 2, studying for 70-528. I've hit a bit of
a brick wall with DataColumn.Expression. As I understand it, this can
be used to (For example) concatenate two...
|
by: cart1443 |
last post by:
So I know I need to add a few more lines somewhere to make this work, but I'm not sure how.
// Lab 3: EmployeeTest.java
// Application to test class Employee.
/* Begin class declaration of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |