I have this homework program, I am a beginner, it is a simple program but it marks me error return value 3221225477 when I try to run it, can someone tell me why?
#include<conio.h>
#include<stdio.h>
main()
{
int i,cs;
float s,sa,nomina=0;
printf("Cuantos sueldos desea capturar?");
scanf("%d", cs);
for(i=1;i<=cs;i++)
{
printf("Captura el sueldo: ");
scanf("%f",& s);
if(s>=2000)
{
sa=s*1.10;
}
else
{
if(s<2000);
}
{
sa=s*1.15;
}
scanf("%f",& sa);
nomina=nomina+sa;
}
printf("El total de nomina de los trabajadores es %.2f: ", nomina);
getch();
}
#include <cstdio>
int main()
{
int i,cs;
float s,sa,nomina=0;
printf("Cuantos sueldos desea capturar?");
scanf("%d", cs);
for(i=1;i<=cs;i++)
{
printf("Captura el sueldo: ");
scanf("%f",& s);
if(s>=2000)
{
sa=s*1.10;
}
else
{
if(s<2000);
}
{
sa=s*1.15;
}
scanf("%f",& sa);
nomina=nomina+sa;
}
printf("El total de nomina de los trabajadores es %.2f: ", nomina);
}
(C++) compiler makes these remarks:
In function 'int main()':
8:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
19:23: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
8:20: warning: 'cs' is used uninitialized in this function [-Wuninitialized]
The first one:
8:19: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int'
refers to scanf("%f", cs);
and that is probably your main issue.
The
19:23: warning: suggest braces around empty body in an 'if' statement
refers to if ( s<2000 ) ;
Check the logic.
Sidenote: IF s is not greater or equal to 2000 THEN s is less than 2000. There is thus no need to test in the ELSE.
Make your compiler verbose and pay attention to what it says. The compiler is your friend.
just a small correction, the first error refers to the scanf("%d", cs); line
note that you didn't take the memory address of the integer scanf("%d", &cs);
Ive had minor problems with 64 bit ints and C routines in C++ on some compilers, as if it tried to use a 32 bit. If it seems like you fixed the code but the answer is weird, replace 3221225477 with something like 31415 and test it. If it works on the small value you may have an issue there.