C++ program for Software Engineering Lab

Discussion in 'C++' started by apply112, Mar 8, 2008.

  1. apply112

    apply112 New Member

    Joined:
    Mar 5, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    :cryin:
    Hi
    I am working as lecturer in CIITM college jaipur.
    I wanted some C++ programs for a course titles "SOFTWARE ENGINEERING LAB".
    Following are some of the programs ,that I want:
    all the below programs,will take a program as input:
    1. A c++ program that takes any program as input and counts the number of lines,blank lines,half lines,multiple lines.
    2. A c++ program to count the number of global,extern,local variables of any input program
    3. A c++ program to count the no of recursive functions used in any input program
    4. a c++ program to count the depth of recursion in any input program.
    5. a c++ program that checks whether all the loops are properly indented or not in any input program
    6. a c++ program that implements a TSR instruction
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    This forum is not for doing your assignment. First you try and if any problem came then 100% you will get solution from this forum.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If you are stuck somewhere we will help you out
     
  4. sorabh284

    sorabh284 New Member

    Joined:
    Mar 25, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    when we pass object as argument to a function, then whethe constructor or destructor are called or not.
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Taking your questions one by one, keeping the numbering, and I assume this is a question, which I will number "7": when we pass object as argument to a function, then whethe constructor or destructor are called or not


    1. A c++ program that takes any program as input and counts the number of lines,blank lines,half lines,multiple lines.

    Trivial to write. If you're really lecturing on a programming course at a university then you should be ashamed of yourself for even thinking of asking someone else to write such an easy program for you. That you're asking someone to write this for you suggests you're a student who is too lazy to do his own homework and masquerading as a lecturer, and hoping that we'll be (a) smart enough to do a good job, (b) not smart enough to notice that's what you're doing and (c) not devious enough to write something that is nearly right but is guaranteed to get you nothing but a big fat FAILED, and possibly expulsion for plagiarism, which academia takes very seriously (when it's not labelled "research"). But maybe you really are a lecturer and I'm guilty of (d) being too cynical.

    2. A c++ program to count the number of global,extern,local variables of any input program

    More difficult because you need to parse the source and headers.
    a. global: this is not too hard; you can ignore all the functions.
    b. extern: trivial, just count the number of externs in the source, although watch out for multiple declarations such as "extern int a,b,c;".
    c. locals: more difficult, because you need to parse the code itself to work out where you are and what's being defined. Still not as complex as a full language parser though because all you're looking for is TYPE VARNAME [assignment] ; although watch out of course for user-defined TYPEs.

    3. A c++ program to count the no of recursive functions used in any input program

    Impossible in the general solution; there are three parts to this:
    a. functions that call themselves. This is relatively easy; in F() { ... } you're just looking for a call to F().
    b. mutually recursive functions, e.g. where F() calls G() and G() calls F(). More difficult still is the case where each function calls several, each of which calls several, of which some may or may not be recursive calls. You probably need to build a function calling tree to analyse this one in full.
    c. a program that uses function pointers and arrays of functions, and/or that does odd things with function pointers (e.g. casting them to different types and passing them into other functions). Quite difficult for a human to figure out and this will be impossible in the general case to automate.

    4. a c++ program to count the depth of recursion in any input program.

    You would need to take the program's input as well. Consider a program that calculates n! where n is a number that the user enters. The depth of recursion will be directly dependent on n and cannot be calculated just by looking at the source code, and of course the rules for a,b and c above need to be considered for a general solution too.

    5. a c++ program that checks whether all the loops are properly indented or not in any input program

    This is relatively trivial because you're checking for specific keywords and counting whitespace at the start of each line in the code block that follows. The difficult bit is going to be in working out what exactly constitutes a loop and it may be easier just to write a program that checks for the indentation of the whole program. This is a relatively easy program to write and again I think you should not be asking others to write this for you if you're going to be teaching programming skills.

    6. a c++ program that implements a TSR instruction

    Assuming you mean terminate and stay resident, this is going to be highly operating system dependent but it should be easy to locate TSR examples.
    You will also need to get some of your own search skills. Looking up obvious terms in Wikipedia for example: http://en.wikipedia.org/wiki/Terminate_and_Stay_Resident

    7. when we pass object as argument to a function, then whethe constructor or destructor are called or not

    If this involves creating a temporary object, yes, the constructor for that temporary object will be called. For example if string::string(char *) exists, and you call func(string x) with func("Hello") then string::string("Hello") will be called to create the temporary string x.

    I don't think you would get a destructor call on passing an object into a function, unless there was some complicated relationship which involves the destruction of some other object in the creation of the temporary. The destructor of the temporary object itself, definitely not; that would be called later (probably when the function exits).
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice