0

if else statement not working with getchar()

#include <stdio.h> int main() { int score = getchar(); if (score >= 90) printf("Top 10%%.\n"); else printf("Less than 90.\n"); return 0; } it gives "less than 90" for all inputs. please help and explain thanks

14th Feb 2020, 10:41 AM
Sanket Ichharam Barde
Sanket Ichharam Barde - avatar
3 Antworten
+ 2
score is interger value then why you are taking Input using getchar() Go here and check again how to take integer input https://www.sololearn.com/learn/C/2914/
14th Feb 2020, 10:48 AM
A͢J
A͢J - avatar
+ 1
Understood thanks
14th Feb 2020, 2:23 PM
Sanket Ichharam Barde
Sanket Ichharam Barde - avatar
0
Getchar is only for getting character , simply take scanf()
15th Feb 2020, 12:54 PM
Shubham Vilayatkar
Shubham Vilayatkar - avatar