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; Originally Posted by lolol lol @ system("pause") uncle that system pause ........ is like getch(); So, if you already know ...

  1. #16
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by lolol View Post
    lol @ system("pause") uncle that system pause ........ is like getch();
    So, if you already know the answer why bother asking?

    Quote Originally Posted by lolol View Post
    and u all take a bath with cold water thanks
    wtf?
    "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

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by lolol View Post
    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
    Yes it is... it shows "Press any key to continue" message. You wanted one, right?

    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
    So print out a message asking if the user wants to run it again and read the input.
    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.

  3. #18
    Banned
    Join Date
    Nov 2007
    Posts
    678
    haha lol ok when you come back read this:
    after printing your great program intro ...
    Calculator 1.0
    blah blah
    just call getch();
    for you it will do, and don't worry the least about portability haha lol

    in each function print the message:
    do it again [y/n]
    and put the code in a loop also. a do while loop is good here.
    in string function you should do almost exact thing as in main.
    just print the menu in a loop, read choice, do blah haha lol
    lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol

  4. #19
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If your instructor has "given you a program", as you say, then post it, already!

    The thing is, short of writing out the whole program, there's no easy answer to such a vague request as you've made.

    And we don't do whole programs hardly at all, because we like to see you learn to program, not just copy from a forum, and also, it takes a lot more time.

    On this forum, you should ALWAYS post the code you have (or pseudo-code if you have no code), and then tell us what *specific* problem you're having, and how to fix THAT problem.

    You'll wind up getting a few fixes, and suggestions, but a whole program - not likely.

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void menu(void);
    void addition(void);
    void division(void);
    void factorial(void);
    void multiplication(void);
    void subtraction(void);
    void stringOps(void);
    
    char A[256] = {'\0'};
    
    int main()   {
    
       printf("\n\nWelcome to My Calculator");
    //etc.
    
       fflush(stdin); //others will tell you it's crap. I'll tell you I use Turbo C/C++ still, and Borland
                            //recommends using fflush(stdin). 
       printf("\n\nPress Any Key to Continue");
       while(!kbhit); //do nothing, notice the semi-colon here.
        
       menu();
    
    
       return 1;
    
    }
    /*everything loops out from your menu() and comes back to it, as well*/
    
    void menu()   {
       char ch;
       
       do  {
    
          printf("\n\n Calculator Main Menu. Please Select One Type of Problem, or Q to Quit")
    
          printf("\n\n A........for Addition\n S......for Subtraction\n F.......for factorial\n D........for division");
          printf("\n G........for string operations\n M........ for multiplication");
    
          fflush(stdin);
          scanf("%c" &ch);
          ch = toupper(ch);  //check the header needed for this, 
    
          switch (ch)   {
             case 'A': addition(); break;
             case 'S': subtraction(); break;
             case 'F': factorial(); break;
             case 'D':division(); break;
             case 'G': stringOps(); break;
             case 'M': multiplication(); break;
             default: 
                printf("\n I didn't understand that choice, please choose again");
          }
    
    
       }while(ch != 'Q');
    }
    That's all the time I've got right now. Good luck w your program.







    }

  5. #20
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Don't recommend undefined behavior to others. Recommended or not, there are other ways of doing it.
    It's really time you got rid of Turbo C.
    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.

  6. #21
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    hahah i just got back and i found most of you are so funny.. now listen to the question carefully please.. "WHERE ON EARTH DID I SAID THAT I WANT THAT ........ TO APPEAR ON SCREEN THAT MY CALCULATOR WELCOME MSG?" ROFLLLLLLLLLLLL I only said that when that msg is display there will be a msg "Press any key" Then if a user press'es any key like shift a b c or whatever he hits, THE MENU should open lololol and btw when i got back from playing mohaa so my brain was fresh so i wrote this ........ in like 5 minutes

    Code:
    #include<iostream.h>
    #include<string.h>
    #include<conio.h>
    #include<stdio.h>
    #include<stdlib.h>
    
    void printing()
    {
    cout<<"A......Addition\n";
    cout<<"S......Subtraction\n";
    cout<<"D......Division\n";
    cout<<"M......Multiplication\n";
    cout<<"F......Factorial\n";
    cout<<"P......Power\n";
    cout<<"G......String Operation\n";
    cout<<"E......Exit\n";
    cout<<"\t\tEnter Your Choice";
    }
    
    
    void Addition()
    {
    char ch;
    while(1)
     {
     int a,b;
     clrscr();
     cout<<"\t\t\t\tAddition\nEnter 1st number:";
     cin>>a;
     cout<<"\nEnter 2nd number:";
     cin>>b;
     cout<<"\n"<<a<<"+"<<b<<"="<<(a+b);
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
        break;
          }
       }
    
    }
    
    
    void Subtraction()
    {
    char ch;
    while(17)
     {
     int a,b;
     clrscr();
     cout<<"\t\t\t\tSubtraction\nEnter 1st number:";
     cin>>a;
     cout<<"\nEnter 2nd number:";
     cin>>b;
     cout<<"\n"<<a<<"-"<<b<<"="<<(a-b);
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
        break;
          }
       }
    
    }
    
     
    
    void Division()
    {
    char ch;
    while(1)
     {
     int a,b;
     clrscr();
     cout<<"\t\t\t\tDivision\nEnter 1st number:";
     cin>>a;
     cout<<"\nEnter 2nd non-zero number:";
     cin>>b;
     cout<<"\n"<<a<<"/"<<b<<"="<<(a/b);
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
        break;
          }
       }
    
    }
    
     
    
    void Multiplication()
    {
    char ch;
    while(1)
     {
     int a,b;
     clrscr();
     cout<<"\t\t\t\tMultiplication\nEnter 1st number:";
     cin>>a;
     cout<<"\nEnter 2nd number:";
     cin>>b;
     cout<<"\n"<<a<<"*"<<b<<"="<<(a*b);
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
        break;
          }
       }
    }
    
    
    void Power()
    {
    char ch;
    while(1)
     {
     int a,b;
     clrscr();
     cout<<"\t\t\t\tPower\nEnter number:";
     cin>>a;
     cout<<"\nEnter its power:";
     cin>>b;
       for(int i=1;i<b;i++)
        a*=a;
    
     cout<<"\n"<<a<<"^"<<b<<"="<<a;
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
        break;
          }
       }
    }
    
    
    void Factorial()
    {
    char ch;
    while(1)
     {
       int a,c;
       clrscr();
       cout<<"\t\t\t\tFactorial\nEnter a number:";
       cin>>a;
       c=a;
       for(int i=c-1;i>0;i--)
        a*=i;
       cout<<c<<"!="<<a;
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
          break;
          }
       }
    }
    
    
    void printstr()
    {
    clrscr();
    cout<<"\nR.....Reverse";
    cout<<"\nC.....Concatenation";
    cout<<"\nX.....Copy";
    cout<<"\nL.....Length";
    cout<<"\nB.....Back";
    cout<<"\nEnter Your Choice";
    }
    
    //    STRING PORTION  START //
    
    
    void reverse()
    {
    char ch;
    while(1)
     {
       clrscr();
       char str[100];
       cout<<"\nEnter a String:";
       scanf("&#37;s",&str);
       printf("\nReverse is %s",strrev(str));
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
          break;
          }
       }
    }
    
    
    void concat()
    {
    char ch;
    while(1)
     {
       clrscr();
       char str[100],str1[100];
       cout<<"\nEnter 1st String:";
       scanf("%s",&str);
       cout<<"\nEnter 2nd String:";
       scanf("%s",&str1);
       cout<<str<<"+"<<str1<<"=";
       cout<<strncat(str,str1,strlen(str1));
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
          break;
          }
       }
    }
    
    
    void copy()
    {
    char ch;
    while(1)
     {
       clrscr();
       char str[100],str1[100];
       cout<<"\nEnter 1st String:";
       scanf("%s",&str);
       cout<<"\nEnter 2nd string";
       scanf("%s",&str1);
       clrscr();
       cout<<"1st String="<<str;
       cout<<"\n2nd String="<<str1;
       cout<<"\nString 1 copied to string 2.....";
       strcpy(str,str1);
       cout<<"\nString 1="<<str;
    
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
          break;
          }
       }
    }
    
    
    void length()
    {
    char ch;
    while(1)
     {
       clrscr();
       char str[100];
       cout<<"\nEnter a String:";
       scanf("%s",&str);
       cout<<"\nLength of"<<str<<"is  "<<strlen(str);
       cout<<"\nDo you want to run again?(Y/N)";
       ch=getch();
       if(ch=='n' || ch=='N')
        {
          clrscr();
          break;
          }
       }
    }
    
    
    void Strings()
    {
    cout<<"\t\t\t\tString Operations\n";
    char ch='Y',str[10];
    while(ch!='b' || ch!='B')
     {
       printstr();
       ch=getch();
       switch(ch)
        {
          case'R':
          case'r':
           reverse();
             break;
          case'C':
          case'c':
           concat();
             break;
         case'x':
          case'X':
           copy();
         case'l':
          case'L':
           length();
             break;
          case'b':
          case'B':
           break;
          default:
           clrscr();
          }
          if(ch=='b' || ch=='B')
           {
           clrscr();
           break;
             }
       }
    }
    
     
    
     
    
     
    
    void main()
    {
    char ch1='Y';
    cout<<"\n\n\n\n\t\t\tWelcome\n\n\t\t\tMy Calculator\n\n\t\t\tVersion 1.0\n\n\t\tPress any key.......";
    getch();
    clrscr();
    
    while(ch1!='e' || ch1!='E')
     {
    
       printing();
       ch1=getch();
     switch(ch1)
        {
          case'A':
          case'a':
           Addition();
             break;
          case'S':
          case's':
           Subtraction();
             break;
          case'D':
          case'd':
           Division();
             break;
          case'M':
          case'm':
           Multiplication();
             break;
          case'F':
          case'f':
           Factorial();
             break;        
          case'P':
          case'p':
           Power();
             break;
          case'G':
          case'g':
           Strings();
             break;
          case'E':
          case'e':
           exit(0);
          default:
           clrscr();
    
      }
    
     }
    
    }
    LOLLOLOLOLOL I R LULZ

  7. #22
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Please stop 'loling', why are you using conio.h?

    And this isnt' C... I'd suggest you study instead of playing 'mohaa'.

    Code:
    switch(ch1)
        {
          case'A':
          case'a':
    What's wrong with,
    Code:
    switch(tolower(ch1))
    {
        case 'a':
    
        ...
    }
    Code:
    void main()
    Naughty.

    Stop lolling all the time and listen to what people are saying.
    Last edited by zacs7; 03-28-2008 at 06:28 AM.

  8. #23
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    oh btw ty Adak for your reply, it was somewhat close but your reply was the most appropriate amoung all others, thanks to all others as well (just for the formality) not that they did something great haha

    Edited to remove anti-semitic comment. I'll leave the rudeness in so people know who they're dealing with. -- CornedBee
    Last edited by CornedBee; 03-28-2008 at 06:48 AM.

  9. #24
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    Quote Originally Posted by zacs7 View Post
    Please stop 'loling', why are you using conio.h?

    And this isnt' C... I'd suggest you study instead of playing 'mohaa'.

    Code:
    switch(ch1)
        {
          case'A':
          case'a':
    What's wrong with,
    Code:
    switch(tolower(ch1))
    {
        case 'a':
    
        ...
    }

    uncle, when you only do 'a' then when a user hits 'a' (small case) only then will it work, when user hits "A" capital A then it wont work, thats why uncle u need to do it for both ahhahahahha ?? ??

  10. #25
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    edit: zacs7 sorry but i cant stop loling at you guys, dont say stuff that dont make me lol and i wont lol

  11. #26
    Registered User
    Join Date
    Mar 2008
    Posts
    14
    oh i forgot to mention in the above post .. "And its not c" LOOOOOOOOOL this is perfecty c, just edit cout to printf and cin to scanf .. and as for libraries, they can be included in both c or cpp so what are you talking about? UNCLE

  12. #27
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > this is perfecty c, just edit cout to printf and cin to scanf
    Er... you know how stupid that sounds?

    And please stop calling me Uncle, unless you are actually my nephew -- which I hope not.
    Last edited by zacs7; 03-28-2008 at 06:41 AM.

  13. #28
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by lolol View Post
    uncle, when you only do 'a' then when a user hits 'a' (small case) only then will it work, when user hits "A" capital A then it wont work, thats why uncle u need to do it for both ahhahahahha ?? ??
    That's what the tolower() function is for. It transforms a char from uppercase to lowercase.
    "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

  14. #29
    Banned
    Join Date
    Nov 2007
    Posts
    678
    lol haha
    hey i sent you a pm lol
    but you seem so lol that you did not notice it yet lol
    when will you be done with your mohaaa lol

    lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol lol

Page 2 of 2 FirstFirst 12
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