How do you determine a circular queue is full?
You could check the last element's next() node to see if it's null. If it's not null, then you've pointed your end pointer to the first element, and the queue is full.
ENTRY - CONTROLLED LOOP EXAMPLE
Consider the following code fragment:
:
for(int a=1;a<=10;a++)
{
How do you include Trigonometry in C?
You don't. You can include math.h though, and use its functions eg. sin, cos, tg, sqrt, etc.
A merchant statement is a written record prepared by the processor (usually once a month) which lists all the transactions for the account, including fees charged.
What is the algorithm to find largest node in a binary search tree?
Since a binary search tree is ordered to start with, to find the largest node simply traverse the tree from the root, choosing only the right node (assuming right is greater and left is less) until you reach a node with no right node. You will then be at the largest node.
for (node=root; node!= NULL&&node->right != NULL; node=node->right);
This loop will do this. There is no body because all the work is done in the control expressions.
Difference between array and union?
All the members of the structure can be accessed at once,where as in an union only one member can be used at a time. Another important difference is in the size allocated to a structure and an union. for eg: struct example { int integer; float floating_numbers; } the size allocated here is sizeof(int)+sizeof(float); where as in an union union example { int integer; float floating_numbers; } size allocated is the size of the highest member. so size is=sizeof(float);
Why object is known as basic run-time entity?
coz at the run time object is provided memory , that's why object is called run time entity .
How do you write a program in c to print the first five prime numbers?
In order to print the first 10 prime numbers you need a function to determine if a given value is prime or not. The following algorithm is the standard method of doing so:
1. Let n be the value.
2. If n < 2 then return false.
3. If n is even then return true if n is 2, otherwise return false.
4. Let divisor = 3.
5. If divisor is greater than the square root of n then return true.
6. If divisor is a factor of value then return false.
7. Let divisor = divisor + 2.
8. Go to step 5.
This algorithm can be efficiently implemented in C++ as follows:
bool is_prime (const unsigned n)
{
if (n<2) return false;
if (!(n&1)) return n==2;
const unsigned m = static_cast<unsigned>(std::sqrt (static_cast<double>(n)));
for (unsigned d=3; d<=m; d+=2)
if (!(n%d)) return false;
return true;
}
With this function defined, we can now go ahead and write the complete program:
#include<iostream>
bool is_prime (const unsigned n) {/*as above*/}
int main()
{
std::cout << "First 10 primes:\n";
unsigned primes = 0;
unsigned num = 0;
while (primes < 10)
{
if (is_prime (num))
{
std::cout << num << std::endl;
++primes;
}
++num;
}
}
What is the use of switch statement in java?
In java, a switch statement is used to simplify a long list of 'if' statements. A switch statement takes the form of:
switch (variableName){
case condition1; command1;
case condition2; command2;
...
}
C program To sort a string in ascending order?
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j,d;
char ch[20],temp;
clrscr();
printf("\nEnter the no.of string:");
scanf("%d",&d);
printf("\nEnter the strings:");
for(i=0;i<d;i++)
{
gets(ch[i])
}
printf("\nThe strings are:");
for(i=0;i<d;i++)
{
printf("\n%s",ch[i]);
}
for(i=0;i<d;i++)
{
for(j=i+1;j<d;j++)
if(ch[i]>ch[j])
{
temp=ch[i];
ch[i]=ch[j];
ch[i]=temp;
}
}
getch();
}
What are the kinds of conditional statement in foxpro with syntax?
The conditional statement in foxpro is DID YOU GET IT
Branching in 'C' (or any other programming language) is where the flow of execution of code can change depending on some test condition. In 'C', this can be achieved with the "if" statement or the "switch" statement:
void branching (int i)
{
if ( i < 10) {
// Branch 1 - less than 10
printf("i is less than 10");
}
else {
// Branch 2 - 10 or more
printf("i is greater than or equal to 10");
}
}
What is style of function is not obsolete in c language?
Old:
function (par1, par2)
int par1;
char *par2;
{...}
New:
int function (int par1, char *par2)
{...}
Difference between do while and for loop?
for loop it consists of 3 parts 1. initialization 2. condition 3. incrementation like
for(i=1;i<=10;i++).This loop executes 10 times.
While loop: This is an entry check loop. First it checks for the condition and if the condition is true then only loop will be executed and this continues till the condition becomes false.
ex: i=0;
while(i<10)
{i++;
} This loop executes 10 times.
Do loop: This is an exit check loop. This executes the loop at least once even when the condition is false.
ex: 1=0;
do
{
i++;
}while(i<10);
GB is acronym for gigabyte and is used to indicate storage capacity on a computer. A gigabyte is 2^30 bytes or 1,073,741,824 bytes.
Note that disk manufacturers and memory chip manufacturers use different notations. Memory chips are precisely specified such that a 1 GB memory chip is guaranteed to provide storage for exactly 1,073,741,824 bytes. However, hard drives only give approximate storage capacities such that 1 GB only guarantees storage capacity for at least 10^9 bytes, or 1 billion bytes, which is the equivalent of a 0.93 GB memory chip.
Technically, hard-drive manufacturers use the correct notation since the prefixes kilo-, mega- and giga- literally equate to some power-of-ten (10^3, 10^6 and 10^9 respectively). However, it is not possible to create a memory chip with exactly 10^3 bytes, it has to be an exact power-of-two (2^10, 2^20 and 2^30, respectively).
The reason memory has to be an exact power-of-two stems from the way in which memory is addressed on a binary computer. In order to address 1000 bytes we'd need at least 10 bits in the range 0000000000 through 1111100111 (0 to 999 decimal) which means there are 24 invalid addresses in the range 1111101000 through 1111111111 (1000 to 1023 decimal). This over-complicates circuit design; it's much easier to make all bit patterns valid by adding on those missing 24 addresses thus giving us the full kilo-binary-byte capacity of 1024 bytes. Hard-drive manufacturers are less constrained in the way storage is addressed, because the addressing is subject to the operating system and the way in which the hard-drive is formatted. Typically, a hard-drive is divided up into addressable clusters which are themselves some power-of-two bytes in length, such as clusters of 512, 1024, 2048 or 4096 bytes.
In an effort to avoid confusion, the terms kilo-binary-byte (KiB), mega-binary-byte (MiB) and giga-binary-byte (GiB) are used to indicate precise memory capacities while KB, MB and GB are used to indicate the more generalised hard disk capacities. However, these terms is not widely adopted. For instance, Windows operating systems use the term KB to mean 1024 bytes whether reporting memory capacity or hard drive capacity, hence a 300 GB hard-drive only has capacity for 279.4 GB of storage on Windows. But 279.4 GB is 300 billion bytes so, strictly-speaking, it is quite correct to call it a 300 gigabyte drive.
How do you write a computer program to arrange numbers in ascending order?
#include
int main()
{
int num[100];
printf("please input your numbers.enter any letter for the end\n");
int i=0,j=0,k=0;
while(scanf("%d",&num[i++]));
i--;
printf("you input %d numbers\n",i);
for(j=i-1;j>=0;j--){
for(k=0;k<=j;k++){
if(num[k]>num[k+1]){
int temp;
temp=num[k+1];
num[k+1]=num[k];
num[k]=temp;
}
}
}
for(j=0;j<=i-1;j++){
if(j%5)
printf("%d ",num[j]);
else{
printf("\n");
printf("%d ",num[j]);
}
}
return 0;
}
Utility programs are non-applications. Applications allow you to work productively with your computer (MSWord, Excel, etc). Utility programs allow you to configure, diagnose, repair or monitor computer activity. Examples of utility programs are SCANDISK (to repair partitions) and FORMAT (to configure partitions). Control Panel applets are also utilities.
What is substr function does in c?
it will give the substring of length(as per the user) from the actual string,and the starting length from where it has to copy the substring from actual should be given by the user.