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 28107 horace1 1,510
Recognized Expert Top Contributor
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]);
-
}
horace1 1,510
Recognized Expert Top Contributor
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 multidimensiona l 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).
I have a dataset as follows (1 week to keep it short):
Employee 1 - Date 1
Employee 1 - Date 2
|
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 employee values(3,'sunil',11,4500)
insert into employee values(4,'sridhar',22,2000)
insert into employee values(5,'ramesh',33,12000)
insert into employee values(6,'srini',22,16000)
insert into employee values(7,'sashi',33,54000)
|
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 receive a 6% raise, one rated good will receive a 4% raise, and one rated poor will receive a 1.5% raise. Add the if... else... statements to program Salary to make it run as described above.
//...
|
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 salary.
|
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
40 hours worked by each employee and pays "time-and-a-half" for all
hours worked in excess of 40 hours. You are given a list of the
employees of the company, the number of hours each employee worked
last week and the hourly rate of each employee....
|
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", which depends
on it. SQLSTATE=42893
Then I tried to do
|
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 columns to make a derived
column.
When I run my code, I get this error:
------------
|
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 EmployeeTest class. */
public class EmployeeTest
{
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |