I have wrote a small code to get value from Fahrenheit to Celsius. I wanted to keep inputting data until I press any other key than 'y'. But this loop doesn't work that way and stops after one iteration.
#include <stdio.h>
int main()
{
char ch='y';
int far, cen;
do {
    printf("again\n");
    scanf("%d",&far);
    //cen = (5.0/9.0)*(far-32);//integer division will truncate to zero so we can make 5/9 to 5.0 / 9.0
    cen = (5*(far-32))/9;//or this way we can use this formula
    printf("\n%d\t%d",far, cen);
    printf("ch=%c",ch);
    scanf("%c",&ch);
    }while(ch == 'y');
return 0;
}
What is the problem here? P.S I added a line and made a new code like this
#include <stdio.h>
int main()
{
char ch='y';
int far, cen;
do {
    printf("again\n");
    scanf("%d",&far);//here we press carriage return. this value is in stdin
    //cen = (5.0/9.0)*(far-32);//integer division will truncate to zero so we can make 5/9 to 5.0 / 9.0
    cen = (5*(far-32))/9;//or this way we can use this formula
    printf("\n%d\t%d",far, cen);
    scanf("%c",&ch);//putting a space before %c makes the newline to be consumed and now it will work well
    if((ch == '\r')|| (ch == '\n'))
        printf("1\n");
    printf("ch=%c",ch);//this takes the carriage return in stdin buffer
    }while(ch == 'y');
return 0;
}
I need to know carriage return here is \r or \n?
 
     
     
     
     
     
    