answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Write a program to generate a the Number pattern?

C++:

#include <iostream>

int main()

{

for(int i = 5; i > 0; --i) {

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

std::cout << j << ' ';

}

}

return 0;

}

What condition linear search is better than binary search?

In linear search, the searched key will be compared with each element of the array from the beginning and terminate comparing when the searched key is found or the array is reached. Here time complexity in worst case and average case is O (n).

To find an element quickly we use divide and conquer method by using binary search algorithm. Here probed region is reduced from n to n/2. Time complexity is O (log2 n), but here the array should be sorted.

But in interpolation search the probed region is reduced from n to n1/2. If the array elements are uniformly distributed the average case complexity is O (log2 (log2n)).

Am also searching for hashing to compare & contrast with above.

What is High Level Languages and Low Level Languages?

High-level and Low-level term are used to differ any computer programming language whether it is easily understandable to human or not.

High Level Language means the language is easily understandable, and
Low Level Language means the language is more to a machine language than human understandable language.
High-level and Low-level term are used to differ any computer programming language whether it is easily understandable to human or not.

High Level Language means the language is easily understandable, and
Low Level Language means the language is more to a machine language than a human understandable language.

What must every c program have?

A main function must be present in every C program.

What are the ways representing an algorithm?

You can represent an algorithm by three different ways:

1. Pseudo Code

2. Structured flow charts

3. Actual code

A statement that contains an error in logic is?

Technically speaking, an "error in logic" (a fallacy) is a case where the premises do not properly support the argument made. Fallacies are not to be confused with factual errors, wherein the error is caused by a lack of proper information.

What are high and low language give example?

Low-level languages, primarily assembly languages, are those with very little abstraction between the source code and the resultant machine code. They are generally machine-dependent languages; that is, they are non-portable between machine types. Each machine type has its own variant of assembly language and requires its own assembler.

High-level languages have a high degree of abstraction between the source code and the resultant machine code. As such, they are generally machine-independent; the same source can be compiled or interpreted upon any machine with a suitable compiler or interpreter. C, C++ and Java are typical examples of high level languages.

What 6 digit number is a multiple of six?

999984

Another perspective:The above answer is, of course nonsense. since you only need to multiply 6X8, then anything LARGER than that, which is again multiplied by either 6 or 8 or both, becomes the next multiple. As there is no upper limit, you can keep going, making the question itself, nonsense. There is no "largest" number of any kind.

What is perl good for?

The Perl Programming system is used to script language for computer tasks or programs. It can write scripts for science, finance, graphics and system administration programs.

An instruction book or program that takes users through a prescribed series of steps to learn a complex program is called a?

An instruction book or program that takes users through a prescribed series of steps to learn a complex program is called a tutorial.

Shell script to add two numbers?

echo "enter the value of a"

read a

echo "enter the value of b"

read b

c=`expr $a + $b`

echo "the sum of a and b is $c"

Or, alternatively, one could also...

#!/bin/sh

A=5

B=10

C=`echo "$A + $B"|bc -l`

echo "$A + $B = $C"

The above examples illustrate the use of back ticks to fork a child process in shell, however the first example uses the 'expr' command to perform the arithmetic while the second example uses the 'bc' command to perform the calculation. As is nearly always the case in Unix or Linux, there are multiple methods of arriving at the same correct solution.

While the wonderful and all powerful Perl language is perhaps, technically, not a shell, it is theoretically possible to accomplish this goal in Perl as well. Let me see now, to make this example as educational as possible, I'll use a couple of subscripts of the array @array to store our values and an off-the-shelf printf function to display the results of our calculations...

perl -e '@array = (5, 10); printf("%s + %s = %s\n", $array[1], $array[0], ($array[0]+$array[1]));'

As the purpose of this site is to teach, I briefly entertained and then discarded a notion to shoot for maximum obfuscation. Larry, Randy and Nathan will be proud of me I hope. :)

Naturally, there are numerous other ways to accomplish this goal in Linux.

Explain big O and big omega notations.?

omega notation please see this website http://en.wikipedia.org/wiki/Merge_sort

What are the characteristics of distributed operating system?

the characteristics of distributed systems are

1. Heteroginity

2. Openess

3. security

4. transparency

5. concurrency

6. failure handling

7. scalability

by sagar prajapati

What is the main feature in object oriented programming?

[Eating] A Pie:

Abstraction: grouping some data and behaviors into a programming unit with semantic similarity (not randomly), e.g, class, struct

Polymorphism: different object with the same name (same name of a method, variable, but in more than 1 form)

Inheritance: the most important characteristics of an OO language (Object base language would not have this one). It allows a derived class to inherit the data and behaviors from the base class(es), as if those data and behaviors are defined within.

Encapsulation: or information hiding. Object has data members that no one outside of the same class would know what type or shape they are. It also applied to the behaviors.

Disadvantage of Internet?

  • The disadvantages of Internet are that we get addicted to Internet games.
  • Also there are increased chances of hacking a computer.
  • There can also be a misuse if you have entered your name, address, phone no., credit card details etc.
  • The people and kids also become addicted to social networking sites which are very corrupt able and they start spending hours and hours in front of their PCs or even their cellphones.
  • The networking sites like ******** do not delete our information even after we close the account and our information specified is used sometimes even for sending fake mails.

Write a program in c plus plus to create an analog and digital clock using computer graphics?

#include "stdio.h"

#include "conio.h"

#include "dos.h"

void main()

{

int h,m,s;

h=0;

m=0;

s=0;

while(1)

{

if(s>59)

{

m=m+1;

s=0;

}

if(m>59)

{

h=h+1;

m=0;

}

if(h>11)

{

h=0;

m=0;

s=0;

}

delay(1000);

s=s+1;

clrscr();

printf("\n DIGITAL CLOCK");

printf("\n HOUR:MINUTE:SECOND");

printf("\n%d:%d:%d",h,m,s);

}

getch();

}

How do you use conditional in a sentence?

An 'if ' or 'switch'. Some languages also support a ternary operator that can be used to evaluate one of two expressions of the same type.

What is the benefit of using a modular design approach?

Modular architecture is based on the principle of using a single shape and size ,a module,with which to construct a building. The functions of the building are housed in the number of modules required per function.Modular architecture is both easy and complex.Easy,because you can simply add modules as and where needed and each module simply slots into the building without having to make spatial adjustments to the overall plan.Complex,because each module should be capable of fulfilling multiple functions,as well as function independently,while maintaing the strict confines of shape and size of the module.

Modules in modular architecture must be functionally sound,space efficent,asetheically pleasing and flexible enough to form a variety of configurations.

What is the difference between a native compiler and a cross compiler?

A native compiler is one that compiles programs for the same architecture or operating system that it is running on. For instance, a compiler running on an x86 processor and creating x86 binaries. A cross-compiler is one that compiles binaries for architectures other than its own, such as compiling SPARC binaries on a PowerPC processor.
A cross compiler executes in one environment and generates code for another. A "native compiler" generates code for its own execution environment. For example, Microsoft Visual Studio includes a native compiler. It is used on the Windows platform to create applications that are run on the windows platform. A cross compiler could also execute on the Windows operating system, but possibly generate code aimed at a different platform. Many embedded devices, such as mobile phones or wasching machines, are programed in such way. Compilers generating cross-platform hyper code such as compilers for Java or any of the .NET languages fall somewhere in between these two basic compiler categories. Their nature depends on the exact use-case, and the angle under which you look at those when categorizing.

Which languages are the fourth-generation programming languages?

A third generation programming language in essence refers to any high-level

language (except for say, database languages such as SQL). Some well-known

examples are:
PHP, ASP, C, C++, Java, Javascript,

Perl, Python, Pascal, Fortran,

etc.


A fourth generation (programming) language (4GL) is a grouping of programming languages that attempt to get closer than 3GLs to human language, form of thinking and conceptualization.


For example, a typical 4GL command is

FIND ALL RECORDS WHERE NAME IS "SMITH"

What is the flowchart for swapping two variables?

include

#include

void main()

{

int x, y, temp;

printf("Enter the value of x and y ");

scanf("d", &x, &y);

printf("Before Swapping x = %d\ny = %d\n",x,y);

temp = x;

x = y;

y = temp;

printf("After Swapping x = %d\ny = %d\n",x,y);

getch();

return 0;

}

Do you happen to know what a flow-chart is?

Is logo high level language?

Yes. Any language that does not closely resemble the machine code is a high-level language. The more abstract the language, the more high-level it is and the more complex it is to translate into machine code. Logo is highly abstract; it bears no resemblance whatsoever to machine code, therefore it is high level.

Why computer understand 0 and 1?

A bit. Logical and or. Switch on or off. Answer yes or no.


A bit
Each 1 or 0 used in the representation of computer data can be used to present information to you, in order that you may learn it, especially the syntax and forms of the English language, so that when you present questions to global forums where computers also interpret the 1's & 0's to present to people, your question will be understood by those experts whose assistance you so plainly require.

Why might a machine dependent language be more appropriate for writing certain types of programs?

Machine dependent languages often have the advantage of being able to be optimized, since the compiler knows what hardware it's running on. Any program which needs to run efficiently will often benefit from being written in a machine dependent language.