locked
Just try to give the answer for the c question RRS feed

  • Question


  • <!--[if !supportLists]-->

         <!--[endif]-->main()

    {

                 int c[ ]={2.8,3.4,4,6.7,5};

                 int j,*p=c,*q=c;

                 for(j=0;j<5;j++) {

                            printf(" %d ",*c);

                            ++q;      }

                 for(j=0;j<5;j++){

    printf(" %d ",*p);

    ++p;      }

    }



    This is a basic question.... Yet there is fluctuation in answers for all

    Please tell me the answer for this question

    Monday, April 16, 2007 10:16 AM

Answers

  • Answer:
                 2 2 2 2 2 2 3 4 6 5

     

    Explanation:


    Initially pointer c is assigned to both p and q. In the first loop,
    since only q is incremented and not c , the value 2 will be printed 5 times.
    In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.

    Monday, April 16, 2007 10:34 AM
  • I think this is the correct answer anybody having doubt please post ur questions here
    Thursday, April 19, 2007 5:22 AM
  • Tell the answer for this

    f(int x)
    {
    if(x<=0) return 1;
    return f(x-1) + x;
    }
    void main()
    {
    printf("%d",f(7));
    }

    a) 28 b) 29 c) 15 d) None
    Tuesday, April 24, 2007 5:52 PM
  • Give the answers quick and get points for the correct answers
    I wll mark ur answer if ur answer is correct
    Try to use this forum
    Tuesday, April 24, 2007 5:54 PM
  • b) 29
    Tuesday, April 24, 2007 6:19 PM
  • Hey great...
    Can u post the solution here for others use
    Wednesday, April 25, 2007 1:47 AM
  • <!--[if !supportLists]-->  <!--[endif]-->#include<stdio.h>

    main()

    {

    char s[]={'a','b','c','\n','c','\0'};

    char *p,*str,*str1;

    p=&s[3];

    str=p;

    str1=s;

    printf("%d",++*p + ++*str1-32);

    }



    Give the answer n wll mark u as answer

    Wednesday, April 25, 2007 1:52 AM
  • 1 call -  f[ 7 ]

    2 call - f[ 6 ] +7

    3 call - f[ 5 ] + 6+ 7

    .

    ..

    ....

    last call - f[ 0 ] +1+2+3+4+5+6+7

    f[ 0 ] will return 1.

    so ans is 1+1+2+3+4+5+6+7 = 29 

     

    Wednesday, April 25, 2007 9:17 AM
  • Ans : 77

     

    because

    *p=10

    *str1=97

     

    and 11+98-32 = 77

    Wednesday, April 25, 2007 10:57 AM
  • Hey hiren
    How is this "Great yar"
    I am searching the answers for these questions for some time
    Well worsed in C ?
    Wednesday, April 25, 2007 5:10 PM
  • Hey how u got well worsed in C
    Which books u read for this
    Just tell me
    I too want to learn more about programming
    Thursday, April 26, 2007 3:30 PM
  • I read the book of Yashwant Kanitkar & Balagurusami..

    but this problem is very easy...

     

    By the way... Fell free to mark as answer if u like any post....

    Thursday, April 26, 2007 4:57 PM
  • Hey friend
    Just see the thread once
    I hv marked all ur answers as good one
    Then what can i do dear (other than this)
    Friday, April 27, 2007 1:13 AM
  • Yeah.. that I know..

    But keep it continue....

    Friday, April 27, 2007 8:50 AM
  • Yes i wll
    Friday, April 27, 2007 6:28 PM
  • Yes any one can ask question dear....
    We wll try to answer for it

    Saturday, April 28, 2007 5:46 PM
  • Please use this forum effectively
    U can get into it and learn a lot
    Any one can ask ur questions here
    We wll try to give the answers
    Monday, April 30, 2007 6:35 AM

All replies

  • Answer:
                 2 2 2 2 2 2 3 4 6 5

     

    Explanation:


    Initially pointer c is assigned to both p and q. In the first loop,
    since only q is incremented and not c , the value 2 will be printed 5 times.
    In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.

    Monday, April 16, 2007 10:34 AM
  • I think this is the correct answer anybody having doubt please post ur questions here
    Thursday, April 19, 2007 5:22 AM
  • Tell the answer for this

    f(int x)
    {
    if(x<=0) return 1;
    return f(x-1) + x;
    }
    void main()
    {
    printf("%d",f(7));
    }

    a) 28 b) 29 c) 15 d) None
    Tuesday, April 24, 2007 5:52 PM
  • Give the answers quick and get points for the correct answers
    I wll mark ur answer if ur answer is correct
    Try to use this forum
    Tuesday, April 24, 2007 5:54 PM
  • b) 29
    Tuesday, April 24, 2007 6:19 PM
  • Hey great...
    Can u post the solution here for others use
    Wednesday, April 25, 2007 1:47 AM
  • <!--[if !supportLists]-->  <!--[endif]-->#include<stdio.h>

    main()

    {

    char s[]={'a','b','c','\n','c','\0'};

    char *p,*str,*str1;

    p=&s[3];

    str=p;

    str1=s;

    printf("%d",++*p + ++*str1-32);

    }



    Give the answer n wll mark u as answer

    Wednesday, April 25, 2007 1:52 AM
  • 1 call -  f[ 7 ]

    2 call - f[ 6 ] +7

    3 call - f[ 5 ] + 6+ 7

    .

    ..

    ....

    last call - f[ 0 ] +1+2+3+4+5+6+7

    f[ 0 ] will return 1.

    so ans is 1+1+2+3+4+5+6+7 = 29 

     

    Wednesday, April 25, 2007 9:17 AM
  • Ans : 77

     

    because

    *p=10

    *str1=97

     

    and 11+98-32 = 77

    Wednesday, April 25, 2007 10:57 AM
  • Hey hiren
    How is this "Great yar"
    I am searching the answers for these questions for some time
    Well worsed in C ?
    Wednesday, April 25, 2007 5:10 PM
  • Hey !!!

    m still did'nt understand ur sol.

    can u plz elaborate it a little...

    Thursday, April 26, 2007 9:29 AM
  • s[]={'a','b','c','\n','c','\0'};

    so s[0]='a',s[1]='b',s[2]='c',s[3]='\n',s[4]='c',s[5]='\0'

     

    first p=&s[3];

    *p='\n'

    ("%d",*p)=10;

     

    second str1=s

    *str1='a'

    ("%d",*str1)=97

     

    now ++*p + ++*str1 - 32

          = 11 + 98 -32

          = 77

     

    Thursday, April 26, 2007 10:19 AM
  • Hey how u got well worsed in C
    Which books u read for this
    Just tell me
    I too want to learn more about programming
    Thursday, April 26, 2007 3:30 PM
  • I read the book of Yashwant Kanitkar & Balagurusami..

    but this problem is very easy...

     

    By the way... Fell free to mark as answer if u like any post....

    Thursday, April 26, 2007 4:57 PM
  • Hey friend
    Just see the thread once
    I hv marked all ur answers as good one
    Then what can i do dear (other than this)
    Friday, April 27, 2007 1:13 AM
  • Yeah.. that I know..

    But keep it continue....

    Friday, April 27, 2007 8:50 AM
  • Yes i wll
    Friday, April 27, 2007 6:28 PM
  • can i ask ques also?
    Saturday, April 28, 2007 2:25 PM
  • Yes any one can ask question dear....
    We wll try to answer for it

    Saturday, April 28, 2007 5:46 PM
  • Please use this forum effectively
    U can get into it and learn a lot
    Any one can ask ur questions here
    We wll try to give the answers
    Monday, April 30, 2007 6:35 AM
  • there are already threads existing on this topic [c/c++ quiz or examples], why not integrate these seperate threds and keep only the one which is oldest?....otherwise its not fun participating in simultaneous threads of the same origin and same background discussion?
    Wednesday, May 2, 2007 8:50 PM
  • Hey... Hiren,

     

    could u provide me some of the problems and solutions regarding 'C' program??? 

    Monday, May 14, 2007 8:05 AM