Thread: Another question and answer thread

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    2

    Question Another question and answer thread

    help me with this problem..i prefer using nested if..i need to compare with mine..i'm using codeBlocks btw..tqvm

    write a program that will offer interviews to applicants who meets certain age and educational specification.

    How old is the applicant?
    what university? 1)UiTM 2)other
    Field of studies? 1)science 2)art

    the criteria

    science art
    UiTM age>25 25<age<30

    other 25<age<40 25<age<35

  2. #2
    Registered User \007's Avatar
    Join Date
    Dec 2010
    Posts
    179
    Don't ask for homework answers. Write some code and try asking again.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What have you done so far?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    2

    Post help me!!urgent!!

    sorry..this what i've done so far..would tou mind to look and comment at it..i'm using codeBlocks btw..thanks..

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        char u;
        char field;
        int age;
    
        printf("Enter you university: \n");
        printf("Enter your field: \n");
        printf("Enter your age: \n");
    
        scanf("%c", &u);
        scanf("%c", &field);
        scanf("%d", &age);
    
    
        if ( u == 'i')
    
         { if ( age >= 25)
           printf("Congratulation 1");
           else if (age >=25 && age <=30)
           printf("Congratulation 2");
           else
           printf("Sorry 1");
         }
         else
         {
             if(age >= 25 && age <=40)
             printf("Congratulation 3");
             else if (age >=25 && age<=35)
             printf("Congratulation 4");
             else
             printf("Sorry 2");
         }
    return 0;
    
    }
    Last edited by Salem; 02-02-2011 at 07:01 AM. Reason: The tags go around the code!

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    What exactly are you asking about? Does it do what you expect? Use the code tags.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    1. Do you really expect university and field to be just a single character long? You may want to set aside many chars (as in, a char array) to hold those answers.

    2. I am curious as to how you expect any of your else-if statements to be true. For instance, congratulations 1 is printed whenever age is bigger than 25, so the else part of that statement will only happen for people under 25; and no one with an age less than 25 has an age between 25 and 30.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question bout my work
    By SirTalksAlots in forum C Programming
    Replies: 4
    Last Post: 07-18-2010, 03:23 PM
  2. how would you answer this question?
    By smoking81 in forum Linux Programming
    Replies: 3
    Last Post: 09-08-2008, 03:53 AM
  3. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  4. inline fuction please answer this question
    By PLOsTYLe in forum C Programming
    Replies: 0
    Last Post: 09-17-2002, 02:38 AM
  5. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 07:53 AM