Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

When i run this c program, i do'nt receive c value.

+1 vote
asked Nov 1, 2022 by Meir Eini (130 points)
#include <stdio.h>

int main ()
{
  int a;
  float b;
  char c;
 
  scanf("%d%f%c",&a,&b,&c);
   
 
  printf("a = %d\nb = %f\nc = %c\n",a,b,c);
  printf("c=%c\n",c);

  return 0;
}

1 Answer

0 votes
answered Nov 4, 2022 by Peter Minarik (86,180 points)

You do receive the value for c just fine.

Say, your input is: "123 4.567 some more text here". In this case, a will be 123, b will be 4.567 and c will be (not 's', but) ' ' i.e. a space, which follows the value put into b.

If your input would be "123 4.56some more text", in that case, c will be 's'.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...