answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

How can you convert front end alignment data from inches to degrees i need data for a 65 el camino?

Find the sine of the angle from the toe required per side/wheel (inches) divided by the diameter of the wheel rim (inches) For example 1/16th inch total "toe-in" which is 1/32" per side = 0.03125" Assuming a rim diameter of 15" Toe angle per side is sine of 0.003125/15 = 0.002083 equivalent to 0.119366 degrees which is also 7.16 minutes. Total toe-in is double the per side toe-in, in this case 14.32 minutes. Ray

Why Near pointers are used for all code and data references in huge memory model for turbo C?

You may have misunderstood something. Choose Huge Model,and forget about near and far. (Honestly, this topic is outdated by twenty years!)

Write a VB script program to calculate the sum of first 20 even numbers?

dim a(20) as integer

dim i as integer

dim n as integer

private sub command_click()

for i 1 to 20

Next i

a(i) = inputbox ("enter any no.""no.""0")

Next i

for i = 1 to 20

print a(i)

n=n/i

if n mod 2 = 0 then

Next i

end if

msgbox "even numbe"&even

end if

C program to print nos divisible by 8?

#include #include
#define N 100 /* change the upper limit by changing value of N */
int main()
{
int i;
clrscr();
printf("\nPROGRAM TO PRINT NUMBERS DIVISIBLE BY 8 between 1 and 100\n");
for(i=1;i<=N;i++)
{
if(i%8==0)
{
printf("%d\n",i);
}
}
getch();
return 0;
}

Write a program to perform a binary search on an unsorted list of n integers?

#include<iostream>

#include<iomanip>

#include<vector>

#include<random>

// The node class is used to store a value from the

// unsorted list, along with its index in the list.

// The left node points to a tree of nodes where

// all values are less than this node's value. The

// right node points to a tree of nodes where all

// values are greater than (or equal to) this node.

struct node

{

unsigned value;

unsigned index;

node* left;

node* right;

node (unsigned val, unsigned idx)

: value (val), index (idx),

left(NULL), right (NULL) {}

~node ()

{

delete left;

delete right;

}

void insert (node& n)

{

if (n.value<value)

{

if (left)

left->insert (n);

else

left = &n;

}

else

{

if (right)

right->insert (n);

else

right = &n;

}

}

node* find (unsigned val)

{

if (val == value)

return this;

else if (val < value)

return left ? left->find (val) : NULL;

else

return right ? right->find (val) : NULL;

}

};

// The tree class maintains the root node of a binary

// search tree (BST). The default constructor builds

// a BST from a vector of values. All other methods

// delegate to the root node.

struct tree

{

node* root;

tree (const std::vector<unsigned>& v)

: root (NULL)

{

for (unsigned i=0; i<v.size(); ++i)

{

node* n = new node(v[i], i);

if (!root)

root = n;

else

root->insert (*n);

}

}

~tree ()

{

delete root;

}

node* find (unsigned value)

{

return root ? root->find (value) : NULL;

}

};

// A helper function to determine if a value exists

// in a vector or not.

bool exists(std::vector<unsigned> vect, unsigned num)

{

for (unsigned i=0; i<vect.size(); ++i)

if (vect[i] == num )

return true;

return false;

}

int main()

{

// random number generator (range: 1 to 15)

std::default_random_engine generator;

std::uniform_int_distribution<unsigned> distribution (1, 15);

// create an unsorted list with 10 random numbers and print them

// in the order they are generated

std::vector<unsigned> vect;

std::cout << "Unsorted list: ";

unsigned nums = 10;

while (nums--)

{

do

{

unsigned num = distribution (generator);

// ensure num is unique!

if (!exists (vect, num))

{

vect.push_back (num);

std::cout << std::setw(3) << vect.back();

break;

}

} while (true);

}

std::cout <<std::endl;

// create a binary search tree from the vector

tree bst (vect);

// now go find all the numbers in the tree and show where they

// reside in the list (include all the missing numbers)

for (unsigned num=1; num<=15; ++num)

{

if( node* n = bst.find (num))

{

std::cout << num << " was found in the tree";

std::cout << " and is at index " << n->index;

std::cout << " in the list" << std::endl;

}

else

std::cout << num << " could not be found in the tree" << std::endl;

}

}

How do you store a number of integers entered by the user in an arra with C?

You can use dynamic arrays. Malloc, realloc and free play crucial roles. You can also substitute calloc for malloc. Below is a sample code:

#include


#include



int

main(){
int

n = 10

, noofnumbers = 0

, num, i;

int

*arr = (

int

*)malloc(n*

sizeof

(

int

));

//first creating an array of size 10 - you can even skip this part and directly go for expanding an array every time an element is entered
if

( !arr ){
printf(

"No space in memory\n");


return

(1

);
}
while

( scanf("%d"

, &num) != EOF){
if

( noofnumbers < n){
arr[noofnumbers] = num;
noofnumbers++;
}

else

{

//when more than 10 numbers are added increasing the size accordingly
int

*temp = (int

*) realloc(arr, (++n)*sizeof

(int

));//realloc for reallocating the memory
if

( temp == NULL

){
printf("Not enough space\n"

);
break

;
}
else

{
arr = temp;
arr[noofnumbers] = num;
noofnumbers++;
}
}
}
printf(

"the numbers are:\t");


for

( i = 0

; iprintf("%d\t"

, arr[i]);
printf("\n"

); free(arr);//freeing the memory space
return

0

;

}

What Linked list uses.type of memory allocation?

Linked lists use dynamic memory allocation (also called "heap memory allocation", as the linked list is stored in heap memory).

When no semicolon is used after printf statement what will be the output?

A semi-colon denotes the end of a statement. If you omit the semi-colon, the statement will extend into the next expression and this will result in a compiler error because a semi-colon will have been expected at the end of the first expression.

What is the difference between directions and instructions?

Directions direct you in a direction. Like directions to grandma's house.

Instructions explain how to do something. Like an instructor instructs how to solve a math problem.

If you want to take it literally it seems quite simple.

C program that converts the input dollars into its equivalent peso exchange rate?

void main() { float dlr; float peso(float d); clrscr(); printf("Enter the amount of dollors with you: "); scanf("%f",&dlr); printf("\nYour dollars are equivalent to %.2f peso",peso(dlr)); getch(); } float peso(float x) { return x*51.60; }

Why far pointer is not there in Linux?

Pointer types are very specific to the compiler used and oftentimes subject to the target architecture. The concept of a near/far differentiation may not have any meaning on the memory model of your target. This has nothing to do with Linux or whatever OS you choose to use. More information should be provided with the documentation of your compiler.

How you run C plus plus compiler in windows 2007?

There is no operating system known as "Windows 2007". The only Microsoft operating system released in 2007 was Microsoft Windows Server 2008. Microsoft Windows Vista was released earlier in 2006 and has since been superseded by Microsoft Windows 7 (released in 2009), Microsoft Windows Server 2012, Windows 8 (2012), Microsoft Windows Server 2012 R2 and now Microsoft Windows 8.1 (2013).

As to how you run a C++ compiler on Microsoft Windows (regardless of the version), you first have to download or buy a compiler as well as a linker and a resource compiler. However, compilers and linkers are not generally available separately, they usually come as part of an Integrated Development Environment (IDE), which includes project management facilities and code editors. Your IDE documentation will tell you how to run the built in compiler from the command line, however in an IDE this is seldom necessary as all compilation and linking can be achieved from within the IDE itself.

Why is cross-platform connectivity important to many computer users?

Users want to communicate with one another, without being restricted by incompatibility between different types of computers.

Use the control variable during the execution of the loop?

Control variable which is used in control structures.

e.g. for(int i=0;i<10;i++)

{

// body of loop

}

In above example i is a control variable. The scope of i is only in body of loop.

Out of body the scope of all control variables are lost.

What is WWW interface mean?

A computer or other device that will communicate with the WWW (world wide web)

Dry run technique in c language?

dry run is nothing but manual compilation of code with an example for written steps to check whether the code for particular problem is solving or not.....if it not happens change code accordingly...........

Is there scared straight programs n Delaware?

There is no specific "Scared Straight" program in Delaware.

However there are similar programs for troubled youths in Delaware that may be worth looking into.

A company called Winggate hosts wilderness boot camps to therapise troubled youths.

There is also a facility called New Castle Region Detention Center, which houses youths and teaches them the correct paths to follow.

You can ask your local authorities for advice and information on such programs in your local area.

How do you read one dimensional array of integers for highest integer?

Sample code is as follows:

#include <stdio.h>

void main()

{

int i = 0;

int final_number = 0;

int array[] = {-2,-6,2,4,1,6,8,20,-55};

for(i = 0; i < (sizeof(array)/sizeof(array[0])); i++)

{

if(array[i] > array[i + 1])

final_number = array[i];

}

printf("%d", final_number);

}

Tried in MinGw:

Output: 20

Why do you need translator according to compiler design?

the PC or computer ONLY UNDERSTAND 0 and 1 (Binary Code) which is a switch between on and off in electric current. if we do not use translators or compilers we will have a hard time trying to program the PC to do something so we use something more understandable(command syntax) to "tell" the PC what to do

Singly list program using data structures in C?

//Singly linked list:

#include<stdio.h>

#include<stdlib.h>

typedef struct list

{

int data;

struct list *next;

}node;

node *head = NULL;

node* create_node()

{

node *new1 =malloc(sizeof(node));

printf("\nEnter data:");

scanf("%d",&new1->data);

new1->next = NULL;

return(new1);

}

void insert_beg()

{

node *new1;

if(head 1)

insert_beg();

else

insert_after();

break;

case 3: search();

break;

case 4: display();

break;

case 5: printf("\nEnter the data to be found");

scanf("%d",&x);

find_prev(x);

break;

case 6: deletion();

break;

case 7: exit(0);

}

printf("\n\n");

}while(ch != 7);

getchar();

return 0;

}

Write a c program to sort an unsorted stack?

A stack is implicitly sorted by hierarchical nested order. It does not make sense to sort a stack.

Do you mean a list? If so, please ask the question again.

What is involved in CEA testing?

Determination of the CEA level is a laboratory blood test. Obtaining a specimen of blood for the study takes only a few minutes. CEA testing should be covered by most insurance plans.

Powers that only Congress can exercise are called what?

Legislative Powers are exclusive to Congress. The Constitution separates the powers of government so that no branch becomes too powerful.