In: Computer Science
i keep getting return value ignored and and conversion from double to float , possible data loss dont know how to fix the mistakes. if you could please fix it.
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#include
#include
void O_Read_age_1()
{
   int sum = 0;
   int i;
   for (i = 1; i <= 2; i++)
   {
       int temp;
       printf("please enter the age of
employee %d:", i);
       scanf("%d", &temp);
       sum += temp;
   }
   printf("\n");
   printf("The total age of all employees is%d\n",
sum);
   return;
}
float O_Read_Salary_1()
{
   float sum = 0;
   int i;
   for (i = 1; i <= 2; i++)
   {
       printf("PLease enter the salary of
the employee %d:", i);
       float temp;
       scanf("%f", &temp);
       for (; ((temp < 1000)) || ((temp
> 6000));)
       {
           printf("Salary
should be from 1000 to 6000:");
           scanf("%f",
&temp);
       }
       if (temp <= 2150)
       {
           float inc = temp
* 0.2;
           sum +=
temp;
           sum +=
inc;
       }
       else if ((temp > 2150)
&& (temp <= 4150))
       {
           float inc =
temp * 0.15;
           sum +=
temp;
           sum +=
inc;
       }
       else if ((temp > 4150)
&& (temp <= 5150))
       {
           float inc = temp
* 0.1;
           sum +=
temp;
           sum +=
inc;
       }
   }
   return sum;
}
void O_Read_Gender_1()
{
   int males = 0;
   int females = 0;
   int j = 0;
   char ch;
   for (j = 0; j < 2; j++)
   {
       printf("Enter the gender of
employee %d (F or M):", j + 1);
       ch = getchar();
       scanf("%s",&ch);
       printf("\n");
       if (ch == 'F')
       {
           females++;
       }
       else if (ch == 'M')
       {
           males++;
       }
   }
   printf("The number of female employees is %d \n",
females);
   printf("The number of male employees is %d \n",
males);
  
   return;
}
void O_Calculate_Bonus_1()
{
   int bonus = 0;
   printf("Enter the rank of the company: %d");
   printf("\n");
   int Rank;
   scanf("%d", &Rank);
   printf("Enterr the ID of the company: ");
   int id;
   scanf("%d", &id);
   printf("\n");
   if (Rank == 1)
   {
       bonus = 15;
   }
   if (Rank == 2)
   {
       bonus = 10;
   }
   else
   {
       bonus = 5;
   }
   printf("Company ID = %d\n", id);
   printf("Rank= %d\n", Rank);
   printf("Bonus = %d", bonus);
   printf("Student: Bader Alostad Section:O1 ID:45191 -
Semester Spring 2 online Press any button to continue...\n");
   return;
}
int main()
{
   float ans = O_Read_Salary_1();
   printf("\n");
   printf("The Function Read_Salary return the value %f
\n", ans);
   O_Read_age_1();
   O_Read_Gender_1();
   O_Calculate_Bonus_1();
   return 0;
}
float inc = temp * 0.2;
float inc = temp * 0.15;
float inc = temp * 0.1;
inc is float
0.2 , 0.15 and 0.1 are double So changed to
float inc = temp * 0.2f;
float inc = temp * 0.15f;
float inc = temp * 0.1f;
to tell the compiler that it's a float, not a double.
==========================================
After fix the program :
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#include<stdio.h>
#include<stdlib.h>
void O_Read_age_1()
{
   int sum = 0;
   int i;
   for (i = 1; i <= 2; i++)
   {
       int temp;
       printf("please enter the age
of employee %d:", i);
       scanf("%d", &temp);
       sum += temp;
   }
   printf("\n");
   printf("The total age of all employees is%d\n",
sum);
   return;
}
float O_Read_Salary_1()
{
   float sum = 0;
   int i;
   for (i = 1; i <= 2; i++)
   {
       printf("PLease enter the
salary of the employee %d:", i);
       float temp;
       scanf("%f", &temp);
       for (; ((temp < 1000)) ||
((temp > 6000));)
       {
          
printf("Salary should be from 1000 to 6000:");
          
scanf("%f", &temp);
       }
       if (temp <= 2150)
       {
          
float inc = temp * 0.2f;
           sum +=
temp;
           sum +=
inc;
       }
       else if ((temp > 2150)
&& (temp <= 4150))
       {
          
float inc = temp * 0.15f;
           sum +=
temp;
           sum +=
inc;
       }
       else if ((temp > 4150)
&& (temp <= 5150))
       {
          
float inc = temp * 0.1f;
           sum +=
temp;
           sum +=
inc;
       }
   }
   return sum;
}
void O_Read_Gender_1()
{
   int males = 0;
   int females = 0;
   int j = 0;
   char ch;
   for (j = 0; j < 2; j++)
   {
       printf("Enter the gender of
employee %d (F or M):", j + 1);
       ch = getchar();
       scanf("%s",&ch);
       printf("\n");
       if (ch == 'F')
       {
          
females++;
       }
       else if (ch == 'M')
       {
          
males++;
       }
   }
   printf("The number of female employees is %d \n",
females);
   printf("The number of male employees is %d \n",
males);
   return;
}
void O_Calculate_Bonus_1()
{
   int bonus = 0;
   printf("Enter the rank of the company: ");
   printf("\n");
   int Rank;
   scanf("%d", &Rank);
   printf("Enterr the ID of the company: ");
   int id;
   scanf("%d", &id);
   printf("\n");
   if (Rank == 1)
   {
       bonus = 15;
   }
   if (Rank == 2)
   {
       bonus = 10;
   }
   else
   {
       bonus = 5;
   }
   printf("Company ID = %d\n", id);
   printf("Rank= %d\n", Rank);
   printf("Bonus = %d", bonus);
   printf("Student: Bader Alostad Section:O1 ID:45191 -
Semester Spring 2 online Press any button to continue...\n");
   return;
}
int main()
{
   float ans = O_Read_Salary_1();
   printf("\n");
   printf("The Function Read_Salary return the value %f
\n", ans);
   O_Read_age_1();
   O_Read_Gender_1();
   O_Calculate_Bonus_1();
   return 0;
}
NOTE: If you getting any problem , please let me know through comments; I will surely revert back to you.
Please give a up vote .....
Thank you.......