How to perform an operation without showing the result in C?

1

I need a way for the program to run an account between variables x and y and save the result to a z variable, how do I do this in C ?

    
asked by anonymous 01.04.2016 / 02:11

1 answer

4

It would be this:

#include <stdio.h>

int main() {
    int x = 0, y = 0, z = 0;
    printf("Entre com 2 números: ");
    scanf("%i %i", &x, &y);
    z = x + y;
    printf("\n%i", z);
    return 0;
}

See working on ideone .

This line is printf("%i",z, y+x==z); is the biggest confusion. This is adding up the two variables and comparing with z , is not assigning to the variable as requested. And you are sending 2 arguments for formatting printf()

Also the variables have not been initialized and may eventually cause problems. Even the lack of organization makes it difficult to read the code. Organizing makes it easier to understand what is happening.

    
01.04.2016 / 02:28