Write a program that reads a real value and displays its opposite.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    double nb;
    
    printf("Enter a real number: ");
    scanf("%lf", &nb);
    printf("The opposite is %lf \n", -nb);
    
    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Distinct elements in an array