Multiple case selection

Discussion in 'C Programming' started by madarajubalu@gmail.com, May 28, 2014.

  1. Guest

    #include"stdio.h"
    main()
    {
    int i;
    switch(?)
    {
    case 1:
    printf("AB");
    break;
    case 2:
    printf("CD");
    break;
    default:
    printf("CDAB");
    break;
    }
    }

    Question:
    What expression should replace the '?' in the above program to print the result ABCD?
     
    , May 28, 2014
    #1
    1. Advertisements

  2. Stefan Ram Guest

    »main« should be declared to return »int«.

    putchar( 'A' ), putchar( 'B' ), 2
     
    Stefan Ram, May 28, 2014
    #2
    1. Advertisements

  3. And it should be defined with no parameters, not with unspecified
    parameters:
    int main(void)

    And
    #include"stdio.h"
    should be
    #include <stdio.h>
     
    Keith Thompson, May 28, 2014
    #3
  4. Thread drift anyone???

    Or, "I'll take 'Totally Missing The Point' for $800, Alex!"

    Typical of Kiki...
     
    Kenny McCormack, May 28, 2014
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.