Wrong Answer 10% [C]

Larissa de Castro Braga asked 2 years ago

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
    double num=0;
    scanf("%lf", &num);
    if(num>0) printf("+");
    printf("%.4E\n", num);
    return 0;

Remember not post solutions. Your post may be reviewed by our moderators.

  • SHUVRA ADITYA (IIT_NSTU) (͡ ° ͜ʖ ͡ °) replied 2 years ago

    you can use sprintf( ). at first declare a char type variable. char ch[120]; in addition to input number you can use %LE. to print "+" sign use sprint( ) like below: sprintf(ch,"%LE",num); if(ch[0]!='-') printf("+");

    here sprintf( ) convert the number into string and assign it to the char type variable ch.

  • pazuzu replied 2 years ago

    Acredito que o + tem que estar em todos os casos