The Gateway to Computer Science Excellence
0 votes
35 views

GATE 2007 QUESTION(DOUBT)

https://gateoverflow.in/3465/gate2007-it-32

Guys in this question %c is there in printf.......and ans is 25.....but why the ASCII value of 25 is not printed????? As %c is used here. Kindly help where I am getting wrong??

in DS by Active (1.2k points) | 35 views
0

verified... it is wrong in GATE itself...

 

  #include <stdio.h>
           #define EOF -1
           void push (int); /* push the argument on the stack */
           int pop  (void); /* pop the top of the stack */
           void flagError ();
           int main ()
          {         int c, m, n, r;
                     while ((c = getchar ()) != EOF)
                    { if  (isdigit (c) )
                               push (c-'0');
                     else if ((c == '+') || (c == '*'))
                    {          m = pop ();
                                n = pop ();
                                r = (c == '+') ? n + m : n*m;
                                push (r);
                      }
                      else if (c != ' ')
                               flagError ();
             }
              printf("%d", pop ());
}

 

coming to your question

Guys in this question %c is there in printf.......and ans is 25.....but why the ASCII value of 25 is not printed?????

when %c is used.... character printed, when %d is used digits ( ASCII values in case of characters ) printed

0
Thanx...got it

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,666 questions
56,136 answers
193,695 comments
93,468 users