C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Point Out Errors (Q.No. 2)
2.
Point out the error in the program?
#include<stdio.h>

int main()
{
    char ch;
    int i;
    scanf("%c", &i);
    scanf("%d", &ch);
    printf("%c %d", ch, i);
    return 0;
}
Error: suspicious char to in conversion in scanf()
Error: we may not get input for second scanf() statement
No error
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
23 comments Page 3 of 3.

Pooja said:   5 years ago
I couldn't get the answer can you explain properly?
(1)

Rutuja Revadekar said:   4 years ago
I thought the error was in printf statement.

Mishat said:   4 years ago
@All.

#include<stdio.h>

int main()
{
char ch;
int i;
scanf("\n%d", &i);
scanf("\n%c", &ch);
printf("%d %c", i, ch);
getch();
return 0;
}

In the case of integer it is %d and for character it ic %c.
(2)


Post your comments here:

Your comments will be displayed after verification.