#include <stdio.h>
   main() {
    double fahr,cel;
    char again;

    do{
    printf("Enter Dgree");
    scanf("%lf",&fahr);
    printf("In Celsius that is %.1lf\n",(fahr-32)*5.0/9.0);
    printf("agian?");
    scanf("%c",&again);
    } while (again =='y');
}

I don't understand why this won't loop
any ideas?

Maybe do

fflush(stdin);

before your scanf function for the "again" char.

Replace like:

char again[1];
scanf("%c",again);
} while (*again =='y');

But if I put printf after 2nd scanf, its crashing. But the same access in the next line (inside while) is working.
like

main() {
    double fahr,cel;
    char again[1];

    do{
        printf("Enter Dgree : ");
        scanf("%lf",&fahr);
        printf("In Celsius that is %.1lf\n",(fahr-32)*5.0/9.0);
        printf("agian?");
        scanf("%s", again);
        printf("%s", *again);
    } while (*again =='y');
}

Can anyone explain..

Hello xeno86,
Use fflush(stdin) before scanf for again as charley bones said. The loop doesn't work because as you press enter('\n') the '\n' is copied onto the variable again. You can also use flushall() before the scanf() for again.

Thanks for the help guys, its working now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.