> I need help with programming , is there anything I am doing right??

I need help with programming , is there anything I am doing right??

Posted at: 2014-12-18 
The problems I see are:

1. Using printf() with %d, but no int argument following the format string to give a value for the %d.

2. Getting values for n4, n5 and n6 and then overwriting those values with calculations based on n1, n2 and n3. The three GetReal() values are never used.

3. Computing those n4, n5 and n6 values and then ending your program without doing anything with them.

I can't tell what you intend that printf(" first command , n1 \n"); call to do. What is will do is print that text exactly as-is, except that \n is replaced with a newline.

If it's supposed to be a prompt for input, the GetInteger() call should immediately follow the prompt.

If its' supposed to print out the value of n1, you need a % format in the string, and n1 in the argument list. Something like:

printf("The value of n1 is %d\n", n1);

That's about all I can offer. It is not at all clear what you are trying to do. Maybe you can add that information in your next question.

See https://answers.yahoo.com/question/index...

and you can find the answer in gordon's reply.

No one can answer your question until you show genlib.h

Almost everything is Okay in your program.

You have to initialize local variables before they are used, if not, the variable is determined.

To correct these potential errors, you can rewrite slightly your source code like below even if the local variables are to be initialized prior to use, but in this case, a local variable is never initialized automatically.

Initializing any variables explicitly at declaration stage is better for enhancing its readability and preventing potential errors.

#include

#include "genlib.h"

int /* return type is assumed to be int if it is omitted */

main (void) /* to declare it void is good practice */

{

int n1 = 0;

long n2 = 0;

double n3 = 0, n4 = 0, n5 = 0, n6 = 0;

printf(" first command ,n1 \n");

printf("second command ,n2 \n");

printf("third command, n3 \n");

printf("4th command %d ,n4 \n");

printf("5th command %d ,n5 \n");

printf("6th command %d , n6 \n");

n1 = GetInteger();

n2 = GetLong();

n3 = GetReal();

n4 = GetReal();

n5 = GetReal();

n6 = GetReal();

n6 = n1*n2;

n5 = n6*n3;

n4 = n5+n6;

return 0; /* dont forget to write return statement */

}

#include

#include "genlib.h"

main ()

{

int n1

long n2

double n3, n4 , n5 , n6

printf(" first command ,n1 \n");

printf("second command ,n2 \n");

printf("third command, n3 \n");

printf("4th command %d ,n4 \n");

printf("5th command %d ,n5 \n");

printf("6th command %d , n6 \n");

n1 = GetInteger();

n2 = GetLong();

n3 = GetReal();

n4 = GetReal();

n5 = GetReal();

n6 = GetReal();

n6 = n1*n2

n5 = n6*n3

n4 = n5+n6

}

P.S.:1) I didn't put the word command in my "program" , I just wrote it here so you could understand what I mean..I didn't know the exact words for translation..but it has to do with a job payment..

2)This is for Monday ,for school. So,I really need your help , I cant understand what codeblocks tell me :(