C logic doubts [closed]

0

I'm solving a small exercise in C that should print the predecessor and successor of a number on screen. The predecessor prints correctly, but the successor always shows 108. regardless of the number entered. I guess it's kind of crap. How do I resolve this?

#include <stdio.h>
#include<stdlib.h>
int main ()
{
    int numero,antecessor,sucessor;
    printf("\n Escreva um numero inteiro: ");
    scanf("%d",&numero);
    antecessor=numero-1;
    sucessor+numero+1;
    printf("=============================================\n\n");
    printf("\n O antecessor do numero %d e %d\n\n", numero, antecessor);    
    printf("=============================================\n\n");
    printf("\n O sucessor do numero %d e %d\n\n", numero, sucessor);
    printf("=============================================\n\n");

system("pause");    
return(0);
}

IN TIME: I apologize to everyone. The error had nothing to do with rubbish but with typing wrong on my part. Only after posting did I see that the second number (successor) was wrongly given the value assignment.

Instead of writing:

successor = number + 1

I wrote:

successor + number + 1

    
asked by anonymous 20.03.2016 / 13:11

1 answer

1
    antecessor=numero-1;
    sucessor+numero+1;             /* esta linha nao faz nada */
    printf("=============================================\n\n");

Look closely at the second line of the above excerpt:)

    
20.03.2016 / 13:33