Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C++ program for Software Engineering Lab (http://www.go4expert.com/forums/cpp-program-software-engineering-lab-t9189/)

apply112 8Mar2008 20:52

C++ program for Software Engineering Lab
 
: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

asadullah.ansari 12Mar2008 13:17

Re: C++ program for Software Engineering Lab
 
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.

shabbir 12Mar2008 19:37

Re: C++ program for Software Engineering Lab
 
Quote:

Originally Posted by asadullah.ansari
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.

If you are stuck somewhere we will help you out

sorabh284 25Mar2009 22:00

Re: C++ program for Software Engineering Lab
 
when we pass object as argument to a function, then whethe constructor or destructor are called or not.

xpi0t0s 26Mar2009 05:46

Re: C++ program for Software Engineering Lab
 
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/Termina..._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).


All times are GMT +5.5. The time now is 17:35.