Advantages and disadvantages of the programming language FORTRAN?
Up till Fortran 90/95, the language was primarily intended for calculations. It remains one of the best computational languages ever developed, and is still in heavy use in the financial industry.
However, due in large part to disagreements among members of the Fortran development groups, Fortran 77 was deficient in a number of areas. Most or all of these have since been addressed by Fortran 90/95, however, so they do not represent current language deficiencies. These limitations included:
Is the for loop a pretest type of loop?
Pretest loops, such as for-loop, while-loop, execute/evaluate the condition statement first, if the condition is met, then the statements of the loop are executed. If you were referring to the body of the loop being carried out at least once, no, the body will not be touched if the condition fails (pre-test, test BEFORE the [next] execution of the body). But the condition of the loop must have been evaluated at least once.
In contrast to the post-test loops, such as do-while, repeat-until, the condition is evaluated AFTER the [next] execution of the body. It is possible that the condition is never evaluate, and not the entire loop body being executed.
What is readability as a criteria of evaluating programming languages?
Yes. Some computer languages, such as VB, VB.NET, COBOL are designed for business, while Fortran is for engineers and scientists.
Which one is better between Compiler and interpreter?
A compiler is a program that takes a programming language like that of java and then translates it into computer language for the software user. The interpreter just ( just like that of a human interpreter) takes the foreign language which would be that of the programming language and turns it into the machine code. Both of these programs take a high-level programming language and translates them into the machine code, but the interpreter is slower to translate than the compiler because of the fact it processes and interprets each statement many times.
When will lvalue error occur in c?
When there is no addressable value in program, then compiler will give lvalue error.
Lvalue or location value is an address that is stored into while rvalue is the "read" value, ie., value of a constant or the value stored at a location. In the assignment a = 31; we have the lvalue of a used on the left hand side and the integer contant value 31 assigned to this location. In the assignment b = a; we have the rvalue of a (31) used to assign to the lvalue of b . So depending on which side of an assignment, we use the variable a , we get two different behaviors
What is Queue Explain its Operations with example?
A queue is a first in, first out (FIFO) data structure. Queues are typically used to buffer data between an input and an output device, particularly when the input and output devices operate at different frequencies. Typically one thread controls incoming data, pushing data onto the queue structure. Meanwhile another thread pops the first element from the queue and processes it. To prevent data races (where both threads update the queue concurrently) the push and pop operations are mutually exclusive. In order to perform a push or pop, a thread must first acquire a lock. If the lock is already held by another thread, the current thread is blocked. A blocked thread will yield to other threads and attempt to hold the lock on its next time-slice. Meanwhile, the thread that holds the lock can push or pop an element from queue, releasing the lock as soon as it has completed the operation.
Queues are typically implemented using a singly-linked circular list. New elements are pushed onto the tail while existing elements are popped from the head. Constant-time access to both the head and tail is achieved through a single pointer to the tail, which points "forwards" to the head.
Program to find factorial of a number using recursion?
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i=1,fact=1,n;
printf("enter a no.");
scanf("%d"n);
while(i<=n)
{
fact=i*fact;
i++;
}
printf("factorial=%d",fact);
getch();
}
What do you mean by declaration not allowed here in C programming?
Declarations aren't allowed everywhere; you've found a place (after an executable statament, most likely), where a declaration cannot be put.
How is an one dimensional array is represented in memory?
Arrays are allocated as a contiguous block of memory divided into one or more elements of equal size and type. Knowing the start address of the array makes it possible to reference any element within the array through a zero-based index. Multiplying the index by the size of an element determines the offset from the start of the array.
How structure is passed to function using structure pointer?
When you pass an object to a function you are not actually passing the object, you are only passing the object's value. This is what is meant by the term pass by value.
When passing a value to a function there are actually two objects involved in the exchange: the actual argument (the object that is being passed) and the formal argument (the object used by the function). When we call a function that accepts one or more arguments (also known as parameters), the value of the actual argument is assigned to the corresponding formal argument. Thus the formal argument is a copy of the actual argument and any changes made to the formal argument will have no effect upon the actual argument.
When the formal argument is a pointer, however, the value we pass is a memory address. The actual argument can either be a pointer of the same type or we can take the address of an object of the same type using the address-of operator and pass that. Either way, the value we pass is a memory address. We call this pass by reference even though the address is actually being passed by value. Passing by reference means that the formal argument and the actual argument both refer to the same object and offers an efficient means of passing large objects that are too expensive to copy. This includes most structures and unions and all arrays. Note that arrays implicitly decay to pointers and therefore cannot be passed by value. Structures and unions can be passed by value, but if they are larger than a pointer (in bytes) passing by reference is more efficient.
There are four different ways to declare a formal argument as a pointer:
Ideally, functions should declare formal pointer arguments using methods 2 or 4. Both point to constant types so this gives the caller an assurance that the function has no side effects upon the object being passed by reference. Functions that use methods 1 or 3 should be regarded as having side-effects upon the object being referred to. This can be desirable for efficiency reasons, however returning values via arguments (also known as output parameters) should be avoided whenever possible.
Note that it makes no difference if the formal pointer argument is mutable or constant because the formal and actual arguments are still separate objects. Constant formal arguments are only of relevance to the function designer, they are of no importance to the caller. This is true of all values passed to functions whether the value is a memory address or not. What is important to the caller of a by reference function is whether or not the object being pointed at is declared constant or not.
How do you write a c program using functions and array?
Eg:
int main (int argc, char **argv)
{
int i;
printf ("array argv has %d elements:\n", argc);
for (i=0; i return 0; }
The fflush() function writes any buffered data to the specified file stream. When you write data to a file (with a function such as fprintf()), it is actually placed in a memory buffer. The data is only actually written to the file when the buffer is full, the file stream is closed or when fflush() is called.
#include
using std::cin;
using std::cout;
using std::endl;
int main()
{
const int numOfElements = 5;//defines how many elements are in your array
double arr[numOfElements] = {0.0};
cout << endl << "Enter " << numOfElements << " for your array";
for (int i = 0; i < numOfElements; i++)
{
cout << endl << (i + 1) << " element: ";
cin >> arr[i];
}
double sum = 0.0;
for (int i = 0; i < numOfElements; i++)
{
sum += arr[i];
}
cout << endl << "Average is: " << (sum/numOfElements) << endl;
system("PAUSE");
return 0;
}
Why was C programming invented?
Writing operating systems like Unix/Linux and a large part of Windows 3.1 (not sure about later versions of Windows) although some of Windows 3.X was done in Pascal.
Most of the Operating systems used these days are developed using C.
Actually the kernel of the OS is written in C and kernel is the base of any OS
How to excute c program on dos?
Command-line and IDE C compilers: There are two types of C compilers, each of which has advantages and disadvantages: (i) Command-line C compilers and (ii) IDE or Windows C compilers To compile and run a C program using a command-line C compiler, you have to go through the following steps: (i) Write the C program (call it ``myfile.c'') in a text editor or word processor (for example, the simple ``Hello'' program below), (ii) Save it as a file on your computer's hard disk, (iii) ``Compile it'' to a computer-executable program by entering a compile command at a command prompt, for example for the following C compiler programs: gcc -Wall -o myfile myfile.c (using the GNU C compiler, UNIX or Microsoft Windows) cl myfile.c (Microsoft Visual C++ command-line compiler) bcc32 myfile.c (Borland C/C++ compiler, Microsoft Windows) followed by the ``Enter'' key, and finally (iv) Run the program by entering myfile at a command prompt, again followed by ``Enter''. If you want to save the output of ``myfile'' as a text file ``myfile.txt'', enter instead myfile > myfile.txt
Indentation is used to make programming code easier to read?
To make the code easier to read for you and other programmers that might view your work.
What do you mean by arrays and explain how to create and initialize arrays in C?
Arrays are group or set of variables having the same data type. Arrays can hold different values depending on the values assigned to them.
To create (or declare) an array is somewhat similar to declaring a variable. You must first enter the data type, the array name (you can name your array anything you like), then array size enclosed in square brackets.
Example:
int arrNum[5];
Using the example given above, it shows that we declare an integer array with the size of 5. Five (5) is the total elements in an integer array called "arrNum" So there are 0 to 4 (zero to four) arrNum arrays (array counts must always start at zero). Namely:
int arrNum[0];
int arrNum[1];
int arrNum[2];
int arrNum[3];
int arrNum[4];
You can store different integer values at any element of int ArrNum. But, do not assign a value that is beyond the size of the array. It will give you a logical error.
Example:
arrNum[6] = 95;
arrNum[5] = 20;
On the second example above, it will still give you a logical error. We defined arrNum to have 5 elements (from zero to four). So, arrNum[5] is out of arrNum's size capacity. Also, once we declared an array to have a definite size, it cannot be redefined to have more elements than what is declared.
To initialize an array, you may need to use loops, specifically "for loop". You may do it manually (without using loops) but loops are useful with arrays. For example, we want to initialize all elements of arrNum[5] to zero:
int Counter = 0;
int arrNum[5];
for (Counter = 0; Counter < 5; Counter++)
{
arrNum[Counter] = 0;
}
In the example above, we used a for loop to initialize all elements of int arrNum[5] to zero. The loop will only stop if and only if the counter exceeds 4. We borrow the value of the counter to act as the size of the array.
Meanwhile, in using an array of characters (also called character array or String), the size of the string must be the number of string plus one. Example, you wanted to write Fire as the value of string called "Word":
char Word[5]; // Array declaration
Word[0] = 'F';
Word[1] = 'i';
Word[2] = 'r';
Word[3] = 'e';
Word[4] = '\0';
As you can see, we declared an array that is the number of character more than 1. The last element in a string should be a null value denoted by "\0" (backward slash and zero). This will tell the computer that the string will end and no further character will be added.
Jump Statements
Branching is performed using jump statements, which cause an immediate transfer of the program control. The following keywords are used in jump statements:
What is the minimum number of stacks of size 10 required to implement a queue to size 10?
2 stacks required
Can an for loop be terminated with a semicolon in c language?
Sure.
for (i=0; i
or
i=0; do printf ("%d %s\n", i, argv[i]); while (i++
What do you call it when your running more than one program?
That is called multitasking.
That is called multitasking.
That is called multitasking.
That is called multitasking.
What do you call a stack of straw?
A pile of hay may be called a :
hay bale
The this pointer is an implicit, compiler generated pointer to the current object that a method is manipulating. It is used to differentiate scope between parameters and members, in the case where they have the same name. Example...
class myclass {
...
int data1;
...
mymethod(int data1) {
data1 = data1; /*ambiguous */
this->data1 = data1; /* not ambiguous */
}
...
secondmethod(int data2) {
data1 = data2; /* not ambiguous */
}
...
}
Many coders use some prefix, such as underscore, to mark member variables. This works, but is not necessary.