answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Can you specify variable field width in scanf format string?

Answer

You can't specify a variable field with a fixed format string, but you can get around this by making the format string variable:

int width; char format[20]; /* or whatever size is appropriate */ int value; ... sprintf(format, "%%%dd", width); /* generates a string like "%5d" */ scanf(format, &value);

The only drawback to this method, other than requiring two statements, is that the compiler can't do a sanity check on the arguments to scanf like it can when the format is a string constant.

Answer

If you want to specify a variable width in a printf format string (as opposed to scanf), you can do the following:

printf("%*d", width, num);

That will use the value of "width" as the width for formatting the value of "num" as a decimal integer.

What experience do you need to become a computer programmer?

All computer programmers started with no experience in programming. However, to help you to pick up the skill faster and doing better, Math background and typing speed were 2 of my recommendations.

The algebra concept and operations definitely helps your logical thinking and will translate business requirements into code faster than those without math background.

Typing speed, well, just help EVERY one to know what you think on the screen or in the program. I have encountered some better thinkers, but suffer from typing skills that audience (readers, teammates) just became very impatient...(Of course you can have someone transcribe for you)

When making an on-site service call what should you do before making any changes to software or before taking th case off the computer?

The best way to keep your data safe is backing it up onto an external hard drive, which can be found at any electronics store. They vary from $250-$1000+, and can hold as much as 2 TB. Before you make any changes whether software or hardware related make sure to ask permission even if the user has just given you permission to interact with the PC.

Advantages of programmable logic array-PLA?

used as mux and demux , used for implement haff adder $ full adder, by program it

What are the types of computer software?

There are mainly two types of computer software. 1.Application Software. 2.System Software.

Why is using arrays with loops improve program efficiency?

Arrays provide the most compact method of representing one or more element of the same type in computer memory (whether in working memory or on disk). There is absolutely no memory overhead with arrays, other than when the array is allocated on the heap in which case you need to maintain at least one reference or pointer to the allocated memory. The structure of the array is built-in to the array itself, such that one element immediately follows another, and each element is exactly the same length (in bytes). This makes it possible to access any element in the array in constant time using simple pointer arithmetic. That is, knowing the start address of the array allows you to reference any element in the array using a memory offset or suffix operator. The first element is always found at offset zero (the start of the array) while the next is at offset 1. Thus for an n-element array, the final element will be at offset n-1. By offset, we really mean offset * sizeof (type), where type is the type of each element in the array. However, when working with arrays, the language knows the size of each type therefore we just use the offset as a zero-based index, where element 5 will be found at index 4, which is 4 * sizeof (type) bytes from the start of the array.

Given that arrays allow constant-time random access, loops make it extremely easy to traverse arrays from any element to any other element, both forwards and backwards. The loop control variable simply acts as the index to the element we wish to process on each iteration of the loop. We can also choose to skip elements if we're only interested in every other element, or every third element, simply by incrementing the control variable accordingly.

Looping through array indices is only efficient when you actually intend to traverse the array, such as when printing the entire array. When searching arrays for a specific value, loop traversal is the least efficient method. If we plan to search an array many times for many different values, it pays to sort the array first. We can then use the binary search technique, starting from the middle element. If that's not our element, the fact the array is sorted means we can eliminate one half of the array, depending on how the middle value compares to the value we are searching for. We then repeat the process with the remaining half, reducing the remaining elements by half each time until we either find our value, or the remaining half has no elements (in which case the value does not exist).

What programming language are web browsers written in?

Most browsers are written in low-level programming languages.

For instance, Firefox (the source code is at http://lxr.mozilla.org/mozilla1.8.0/source/) is written mostly in C++. It also has large parts written in JavaScript, and a custom language called XUL, that control the "chrome", or the look of the toolbars, menus, and surrounding windows. But the rendering engine (the part that figures out how to display web pages) is written mainly in C++.

What are the commonly used data types in programming languages?

Data types tell the compiler how many bytes will be allocated to the type and how those bytes will be interpreted.

For instance, consider the following 64-bit value:

0100101001100001011011100111010101100001011100100111100100000000

In hexadecimal notation this would be written:

0x4a616e7561727900

But what does this value actually mean? Without knowing the type it's impossible to say. It could be any of the following:

- a big-endian integer: 5,359,686,481,972,721,920

- a little-endian integer: 34,184,235,089,551,690

- a big-endian float: 2.03809e+050

- a little-endian float: 2.26484e-306

- a null-terminated string: "January"

All of these are perfectly valid interpretations for the exact same binary sequence. So in order for the compiler to correctly interpret this binary sequence it has to know what data type is actually being represented by that sequence. If we tell it that the sequence is a string of 8 characters then the compiler will correctly interpret the value as the null-terminated string "January".

What is booting in compiler design?

bootstrapping is a process of writing a compiler in the target programing language which it is intended to compile

How do you overload or override a method?

Any time you have a class that inherits a method from a superclass, you have the opportunity to override the method (unless, as you learned in the earlier chapters, the method is marked final). The key benefit of overriding is the ability to define behavior that's specific to a particular subclass type. The following example demonstrates a Porsche subclass of Car overriding the Car version of the drive() method:

public class Car {

public void drive() {

System.out.println("Generic Car Driving Generically");

}

}

class Porsche extends Car {

public void drive() {

System.out.println("Porsche driving Full Throttle");

}

}

Find the smallest number and its position using array with c coding?

You simply walk through the array and whenever you find a smaller element you remember its value and location.

E.g. If you have an array of integers called pArray that contains 100 elements, here's what the code might look like:

int cPos 0, int nMin pArray[0]; // Provisionally assume the first element is smallest.

for ( int n 1; n < 100; ++n )

{

if ( pArray[n] < nMin )

{

// We've found a new smaller element, record its position and value.

nMin pArray[n];

cPos n;

}

}

What is performance measurement in algorithm?

Performance measurement is concerned with obtaining the space and time requirement of a particular algorithm thus quantities depend on the and absence

used as well as on computer on which the algorithm is run..........

Translating an algorithm into a programming language is called?

Translating an algorithm into a programming language is called coding. A variable declaration tells the operating system to allocate storage space in RAM.

What are the advantages and disadvantages of e-services?

Advantages:

There are advantages while implementing an electronic government. The main advantage of an electronic government this will be to improve the efficiency of the current system. That would in return save money and time. The introduction would also facilitate better communications between governments and businesses. An example would be, E-Procurement facilitates G2G and B2B communication; this will permit smaller business to compete for government contracts as well as larger business. This will have the advantage of creating an open market and stronger economy. Business and citizens can obtain information at a faster speed and it is possible at any time of the day.

In addition, moving away from a heavily paper based system to an electronic system would reduces the need for man power. Thus, this would allow the process to be handled by lesser employees and therefore to reduce operations cost.

The society is moving toward the mobile connections. The ability of an e-government service to be accessible to citizens irrespective of location throughout the country brings the next and potentially biggest benefit of an e-government service. The society is moving toward the mobile connections.

Due to the fact that information and statistics are posted online, the idea of an "opened up" government and made government policy, information (including some socially valuable archival and historical information) and services more available. This would reflect a greater transparency of the service provided by the government .

Disadvantages:

Electronic governments also consist on certain disadvantage. The main disadvantage of an electronic government is to move the government services into an electronic based system. This system loses the person to person interaction which is valued by a lot of people.

In addition, the implementation of an e-government service is that, with many technology based services, it is often easy to make the excuse (e.g. the server has gone down) that problems with the service provided are because of the technology.

The implementation of an e government does have certain constraints. Literacy of the users and the ability to use the computer, users who do not know how to read and write would need assistance. An example would be the senior citizens. In general, senior citizens do not have much education and they would have to approach a customer service officer for assistance.

Studies have shown that there is potential for a reduction in the usability of government online due to factors such as the access to Internet technology and usability of services and the ability to access to computers;

Even though the level of confidence in the security offered by government web sites are high, the public are still concerned over security, fear of spam from providing email addresses, and government retention of transaction or interaction history.

How do you write program c of table 5?

#include
#include
void main()
{ int a,i;
printf("\nThe Multiplication table of 5 is:\n");
for(i=1;i<=20;i++)
printf("%d",a*i);
getch();
}
It will print upto 20.

What is the use of getchar?

gets()

Reads characters from stdin and stores them as a string into str until a newline character ('\n') or the End-of-File is reached.

The ending newline character ('\n') is not included in the string.

getchar()

Returns the next character from the standard input (stdin).

It is equivalent to getc with stdin as its argument. === ===

Write a program that will arrange the elements of a 10-integer array in ascending and descending order?

import java.io.*;

public class descendingorder

{

public static void main(String args[]) throws IOException

{

BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

int i,j,n,t;

int a[]=new int[20];

System.out.println("Enter the number of elements:");

n=Integer.parseInt(in.readLine());

System.out.println("Enter the elements of the array:");

for(i=0;i<n;i++)

{

a[i]=Integer.parseInt(in.readLine());

}

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

if(a[i]>a[j])

{

t=a[i];

a[i]=a[j];

a[j]=t;

]

}

}

System.out.println("The orderer lit...");

{

for(i=0;i<n;i++)

{

System.out.println(a[i]);

}

}

}

Write an algorithm to find the greatest number out of the gioven four numbers?

In C#: int[] list = new int[] { 1 , 2, 3, 4}; int highest = int.MinValue; foreach(int i in list) { if(i > highest) { highest = i; } } Console.WriteLine(highest.ToString() + " is the highest number");

Name of the latest programming language?

Programming languages are invented all the time. The vast majority are simply not used by anyone except the author or a small team with a specific need.

If you are looking for the "best" or "most popular" programming language, you are probably going to start an almighty debate! Tiobe compile a list of most popular programming languages at http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html.

Currently, this is Java, C, C++ then PHP and so on.

What kind of programming language is dbase?

It is a 3rd Generation or High Level language, specifically designed for working with databases, namely dBase ones. It works in a runtime environment so it is an interpreted language, but dBase does contain a compiler. It can also be compiled using a Clipper compiler.

Is SQL a high level language?

Yes, SQL is a high level language, since it allow us to get result without much going into Assembly level instructions, by using interpreter to change our statements/queries into machine level instructions!.