lol need some help :D

This is a discussion on lol need some help :D within the C Programming forums, part of the General Programming Boards category; Hello Ladies and Gentlemen, how are you all? I hope you all are good haha now i wont waste your ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    14

    lol need some help :D

    Hello Ladies and Gentlemen, how are you all? I hope you all are good haha

    now i wont waste your time in any formality etc and i'll get to the point.. our programming sir is a retard and he always give us work to do which he never taught us, for example i remember once in a class he defined "Array" and after just defining it, he told us to take 2 arrays and then swap it, LOLOL WTF? ok now he has given us a program which when executed will display this on screen


    WELCOME
    My Calculator
    Version 1.0
    Press any key to continue.......

    now before i go ahead, wtf should i use when any key is press the menu should be displayed?

    well here's the Menu

    A........for Addition
    S......for Subtraction
    F.......for factorial
    D........for division
    G........for string operations
    M........ for multiplication

    now if u hit A or a a menu should come n do addition etc same for all which is easy but when u hit "G" another menu should come n it should display

    String operations
    R........Reverse
    C........copy

    and etc etc .. lol wtf? how do u do this? and also what do i need to put in start of program so when user press any key it should display the menu, n he also said after each thing is done for example if u hit a for addition n addiiton is done, it should ask u if u want to run it again or no, if u press y then it will run again if u hit n then it goes to menu, also he said "Do NOT use goto as its a poor programing practice" lol wtf so anyone who can help etc can post here




    NOTE-:- PLEASE DO NOT POST IF YOU WOULD LIKE TO CRITICISE OR SAY SOME SMART CRAP LIKE "OMFG WE R NOT HERE TO DO UR HOMEWORK ETC" If you are not dumb you'll know that this is not doing my homework so yeah I repeat people who will criticise are not WELCOME to post, thanks

    HOHO so waiting for some elite replies now

  2. #2
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    and yeah only 19 hours left to submit this program, out of these 19 hours i'll sleep for like 8 hours, and 2 hours ill enjoy / eat etc.. so 8+2 = 10 and 19-10 = 9 .. so you have 9 hours to reply if you would like to, after 9 hours please dont bother to reply as it will be of no importance

    thanks

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,451
    what do i need to put in start of program so when user press any key it should display the menu
    For this kind of thing, you would need to use a non-standard library. So, what compiler and operating system is involved here?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    you should have guessed that when i said our programing sir is a retard, lol.. in this modern age he wants us to use Turbo C/cpp hahaha and i remember a friend doing it without using any library, this key thing i mean.. i know the library ur refering to honey its stdlib.h .. or maybe some else also but duno haha i want it to do it without any lib heh like if(choice==default) or something like that default(); or whatever i forgot it completely .. so tell me what u know ?

    and also, from the pic of yours, are you a women or a male? sorry i cant differentiate from ur hair style, so tell me

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,451
    i know the library ur refering to honey its stdlib.h
    That is a standard C library, though in this case you are talking about input, so it is <stdio.h> instead. The problem is that, using the command line, your users will be required to press enter, but you want them to be able to press any key.

    and also, from the pic of yours, are you a women or a male? sorry i cant differentiate from ur hair style, so tell me
    It is not a picture of me, and I am a guy.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    so how do you do it for press any key

  7. #7
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by lolol View Post
    so how do you do it for press any key
    Do you actually have any code written yet? I'm only asking because it doesn't seem like this assignment is very urgent for you.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,451
    You will have to wait for someone who knows the best solution for this in Turbo C to give you the answer. In the mean time, you could try out one of the suggestions in the FAQ: How can I get input without having the user hit [Enter]?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    Quote Originally Posted by laserlight View Post
    You will have to wait for someone who knows the best solution for this in Turbo C to give you the answer. In the mean time, you could try out one of the suggestions in the FAQ: How can I get input without having the user hit [Enter]?

    quantam lol you dont know our programing sir, that retard is just like a army commander.. the way he orders us is like that of army generals.. once we were sitting in his class and it was 10:50 so he told us that "Submit this thing to me exactly and 11:00 and reach your next class at 11:01 immediatly" lol and he is so strict that dont ask.. once a student while in a exam just looked at the person sitting on the right side of him and he came and canceled his paper just like that lol :S now no one can even look above in his damn test.. as for the program, i can write different functions for it like add etc in 2 minutes, thats not a problem.. the problem is that thing when asking y/n to run program again and another problem is that press any key and other prob is this string operations thingi

  10. #10
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    void multiply();
    void divide();
    void add();
    void substract();
    
    int main()
    {
      int choise;
      printf("Calculator.\n");
      do                      
      {
       puts("MENU: \n");
       puts("1 to multiply.");
       puts("2 to divide.");
       puts("3 to add.");
       puts("4 to substract.");
       puts("5 to exit.");
       scanf(" &#37;d", &choise);
       switch (choise)
              {
               case(1) :
                         multiply();
                         break; //prevents other cases from executing
               case(2) :
                         divide();
                         break;
               case(3) :
                         add();
                         break;
               case(4) :
                         substract();
                         break;
               case(5) : exit(1); 
                         break; 
               }
       }
       while((choise < 1) ||(choise > 5));
    
      getchar();
      getchar();
      return 0;
    }
    
    void multiply()
    {
     float a, b, c;
     puts("Enter numbers: ");
     scanf(" %f", &a);
     scanf(" %f", &b);
     c = a * b;
     printf("Answer: %f\n", c);
     return;
    }
    
    void divide()
    {
     float a, b, c;
     puts("Enter numbers: ");
     scanf(" %f", &a);
     scanf(" %f", &b);
     c = a / b;
     printf("Answer: %f\n", c);
     return;
    }
    
    void add()
    {
     float a, b, c;
     puts("Enter numbers: ");
     scanf(" %f", &a);
     scanf(" %f",  &b);
     c = a + b;
     printf("Answer: %f\n", c);
     return;
    }
    
    void substract()
    {
     float a, b, c;
     puts("Enter numbers: ");
     scanf(" %f", &a);
     scanf(" %f", &b);
     c = a - b;
     printf("Answer: %f\n", c);
    }
    how do i add this "Do you want to run again y/n" thing into each of this? and what abt the key thing if u know hurry reply i gota go to play a game, totaly bored ;X
    and also string operations

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    For a quick and dirt way for "press any key", system("pause") might do the trick.
    As for the yes/no thingy, you make a loop. Loop while the user says "yes."
    In case you don't know loops, there's good tutorials on the site.
    Hang in there! Don't let your retard teacher get to you!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Whether your instructor is a bastard doesn't have anything to do with your programming and if he voids your exam for looking up, he'd probably not be too thrilled with you using this board to get your homework done!
    What exactly is the problem you have with asking "y/n" and you'll need to give us more information on what this string operations thingy is!

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  13. #13
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    im going to play MOHAA and ra2 now, will be back later from gaming den.. if u guys could help plz do, just post that how can i add "if u want to run this program again? y/n" that option into each function ok n also tell me how to make those string operations if one press G a menu should come with string operations, R for reverse C for copy B for back etc..... and also how that key thing, ill check back when here thans

  14. #14
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    This would just take printf and scanf.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    lol @ system("pause") uncle that system pause ........ is like getch(); haha i dont know how is it related for any key pressing hahahha :d anyway
    quantum read above what i said, i want something that when a user press 1 for addition n addition is done like user put 2+2 n result is given 4, it should be asked from user if he want to run it again or no, if he do Y then it should run again and if he do N then it should go to menu
    ok laters

    and u all take a bath with cold water thanks

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Recruit - LOL using C
    By Xei in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 04-25-2003, 05:47 AM
  2. Visual C++ 6.0 Debugs my computer lol
    By RoD in forum Tech Board
    Replies: 9
    Last Post: 03-30-2003, 04:13 PM
  3. lol, funniest acting program EVER -- and i need help with it :(
    By Leeman_s in forum Windows Programming
    Replies: 1
    Last Post: 01-09-2003, 06:27 PM
  4. LoL....stupid newb needs help with Hello world.
    By Unregistered in forum C++ Programming
    Replies: 11
    Last Post: 06-12-2002, 04:48 PM
  5. Lol!
    By no-one in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 02-11-2002, 11:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21