Problem : 1

#include <stdio.h>
#include <string.h>
 
int main() 
{
    char a [] = "12345";
    int i = strlen (a);
    printf ("here is 3 %d\n",++i);
}

// What's the output ? [Do not execute / run]
// post your answer as a comment
// Source : http://www.youngprogrammer.com/

About Tausiq
Studying B.Sc in CSE (Computer Science and Engineering) United International University, Dhaka, Bangladesh.

13 Responses to Problem : 1

  1. Saidul Islam says:

    Should be “here is 3 6″ and a new line.

  2. Nizam says:

    here is 3 6

  3. Faiyaz says:

    here is 3 7

  4. Rony says:

    here is 3 6

  5. Jubair says:

    here is 3 6

  6. Tausiq Ahmed says:

    char a [] = “12345″;
    we haven’t defined the size of the array in declaration. This enables us to initialize values and the compiler will allocate necessary spaces.

    int i = strlen (a);
    The length of the array is determined by the number of character elements. strlen () returns the length of a string. here, i = 5

    printf (“here is 3 %d\n”,++i);
    the value of ‘i’ is pre-incremented. that is, the value of ‘i’ will be incremented before printing.

    and, “here is 3″ is concatenated with the output to fuddle u. :P

    Correct Output : here is 3 6

  7. Shawana says:

    here is 3 6

  8. charan says:

    upload python problems.

  9. Sarwar Chowdhury says:

    Should be “here is 3 6″ and a new line.

  10. razu says:

    should be ‘here is 3 6′

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 48 other followers