answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

How do you create an object type object in c plus plus?

An object is simply an instance of a class.

#include<iostream>

class my_object {};

int main()

{

my_object X; // instantiate an instance of the class my_object, identified as X.

}

Definition of loop and its types and programs in c plus plus?



Executing a segment of a program repeatedly by introducing a counter and later testing it using the if statement.

A sequence of statements are executed until some conditions for termination of the loop are satisfied.

A Program loop consists of two segments:
1.Body of the loop
2. Control Statement


Depending on the position of the control statement in the loop, a control strcture may be classifies either as the 2:

  1. Entry Controlled Loop
  2. Exit Controlled Loop
1.Entry Control Loop-(Pre Test Loop)
The control conditions are tested before the start of the loop execution.
If the conditions are not satisfied , then the body of the loop will not be executed.]
eg:
While Loop

2.Exit Control Loop-(Post Test loop)
The Test is performed at the end of the body of the loop and there fore the body is executed unconditionally for the first time.
eg:
Do-While



while loop
for loop
do-while loop

Why 3rd generation language is a level language?

•Much more portable than low level languages (can be transferred over different computers) •Many tutorials and manual for the languages

•Many prewritten and tested algorithms made (no need to "reinvent the wheel")

•Excellent for general purpose programming

Why high level language is slower then assembly language?

Programs written in a high level language might be slower than ones written in Assembly language; but it is not always so, it is very easy to write un-effective programs in Assembly.

How do you protect your system from hackers?

They usually have high levels of complex neural networking systems and firewalls set up around their information databases to detect any abnormal activity, such as hacking or unauthorized persons attempting to access classified data. They also have hired persons that are trained to handle hacking and tracking situations.

What is expansion of COBOL?

COBOL is the acronym used for Common Business Oriented Language. It is one of the oldest programming language.

If you are preparing for a mainframe job with a skill set of COBOL, you would first like to prepare on the commonly asked cobol interview questions. There are plenty of websites on mainframe offering free interview questions on cobol. Going prepared for an interview makes you feel more confident to others who are less prepared. JCL interview questions, DB2 interview questions and CICS interview questions are also easily available on the internet and you may want to be prepared for these as well if the company offering jobs require these skillsets. If you are really out of touch of mainframe technology and want to brush up on the basics then you may want to go through few mainframe tutorials available on the internet.

What is the return value of getch?

getch(); is used for unbuffered input. e.x:

int main()

{

char num=0;

printf("Press a keyboard button: ");

num = getch(); //This brings in 1 character that the user pressed on the keyboard

printf("\nYou pressed: %c", num); //This prints the character you pressed

getchar(); // I am using getchar(); to stop the program from ending after pressing buttons

return 0;

}

My input will be within the ().

output:

Press a keyboard button: (v)

You pressed: v

EOP //End of program

I hope this has helped you!

What is the difference between recursion and tail recursion?

The original answer really doesn't explain much, and almost nothing that's relevant to the question. (Sorry!) The part about iterations typically involving some kind of loop is on target, though it doesn't really shed much light.

This might best be explained by giving two pseudo-code examples, a function to calculate the factorial of an input argument. For simplicity's sake, since this is just to show examples, we will assume that we can be sure that the argument is a positive integer.

# This is an iterative function to calculate the factorial

Function I-Factorial(x)

Result = 1

For i = 1 to x

Result = Result * i

Next i

Return Result

End Function

# This is a recursive function to calculate the factorial

Function R-Factorial(x)

If x = 1 then

Return 1

Else

Return x * R-Factorial(x-1)

End If

End Function

Instead of stepping through a loop, the recursive function simply invokes itself, each invocation using an argument that's been reduced by 1 until ultimately it receives an argument of "1". Then the call for "R-Factorial(1)" is returned to the call for "R-Factorial(2)", which passes its result up to the call for "R-Factorial(3)", which passes its result up to the call for "R-Factorial(4)", and so on, until the accumulated result has bubbled its way up to the original call for "R-Factorial(x)".

As noted in the original answer, recursive functions can(but do not have to) incur additional overhead in terms of call stacks, memory allocations, and so on. If you write in assembly language (as I used to) and utilize reentrant coding techniques, the overhead is very close to zero.

=========

1. Recursion:

# When a recursive call is made, the method/process copies or clones itself, making new copy of:

* the code

* the local variables (with their initial values),

* the parameters

2. Iteration : there is no recursive call involved that saves a lot of time and space too as no extra space is needed to store each copy generated in recursion.

Iterative codes usually refers to codes that contain explicit iteration processes, that is, loops.

How do you write a program in C to find prime numbers between two given numbers?

i ll give you the logic and if u know a lil bit of c u can make it..

accept the two no's from user==> use scanf

if the 1st no is 2

print that using printf like>>1st no is prime

then put a nested for loop

i.e. for (int i = 1st no ;i <=2nd no; i ++)

{ for (int j= 2 ; j <i; j++)

now check for condition

if i/j==0 then printf not prime

else printf prime

so its over u see.....

C language program to print Pascal Triangle?

#include <iostream.h>

double fact(double n)

{

return (n > 1) ? n * fact(n - 1) : 1;

}

double ncr(int n, int r)

{

return fact(n) / (fact(r) * fact(n - r));

}

int main()

{

for (int i = 0; i < 15; i++)

{

for (int j = 0; j <= i; j++)

cout <<ncr(i, j) << ' '; cout << endl;

}

return 0;

}

What is the difference between a compiler and a text editor?

An editor is just a program in which you write and edit the program. The compiler is used to compile the program, i.e., convert the program to machine understandable code. A development environment often combines the both into an intelligent application called the IDE or Integrated Development Environment.

Is the stack is also known as LIFO?

True, unless you start messing about with the stack pointer.

What types of data must handled and stored properly based on classification markings and handling caveats?

Classified information data must be handled and stored properly based on classification markings and handling caveats.

Do all computers include one of marcian hoff's inventions?

no, his invention was the 4004. many newer inventions have long superseded it, but it was the breakthrough that made the later inventions possible.

Very much like the Fairchild invention of the planar transistor was the breakthrough that made monolithic ICs possible, but ICs aren't just lots of planar transistors, they have other components as well as wiring on the one chip.

What are two examples of conditional loops?

while(condition) {

dosomestuff();

}

for(i = 0; i < 10; i++) {

dosomestuff();

}

What are the advantages and disadvantages of top down and bottom up testing?

Integration testing is a typically incremental process which involves testing whether individual modules within a system interact correctly.

Top-down Integration Testing

Top-down integration testing involves starting at the top of a system hierarchy at the user interface and using stubs to test from the top down until the entire system has been implemented. There is no need for test drivers as the user interface provides the means to enter test data. Using Top-down integration testing means that there is a visible system with a certain level of functionality early on.

Bottom-up Integration Testing

Bottom-up integration testing is the opposite of Top-down integration testing. Sub-systems are initially formed at the bottom of the system hierarchy. These are then tested and added to the modules above them to form larger sub-systems which are then tested. Bottom-up integration testing requires the heavy use of drivers instead of stubs.

Is main method a thread?

No, Main is not a daemon thread in Java. its a non daemon or user thread. Also any thread stem from Main will be non daemon because daemon is derived from parent Thread status.

What are the disadvantages of Command-line interface?

You can not view images with a command line interface.

  • There are no graphics -drag0nhunter1

Compare between network hierarchal and relational model?

1. Relational Model : Newer database model; Network Model - Older database model

2. The network model structures data as a tree of records with each record can have multiple parent and child records, forming a lattice structure.

The basic data structure of the relational model is the table, where information about a particular entity (say, an employee) is represented in columns and rows

3.The relational model has strong mathematical foundation with set theory and predicate logic. Network Model has no strong mathematical background.

4. Relational model is the most flexible of the database models. Network model is not very flexible.

5. Relational model has widespead use. Network model has limited use.

What is difference between stack pointer and program counter?

Both of them are pointers, but otherwise they are completely unrelated. The former points to the current position of the stack, the latter points to the current instruction of the program.

How did C come about?

Programming, its first major application was UNIX.

Why are assemblers used?

to translate mnemonic operation codes to their machine language equivalents and assigning machine address to symbolic labels used by the programmer.