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

What is the term for a group of one or more C statements enclosed in braces?

The term for a group of one or more C statements that are enclosed in braces is called a command block. A command block is a block that is made with the intent to support adventure mode.

What are courtroom interruptions?

Courtroom interruptions are objections and recesses.

Write a program in C to check whether a given number is odd or even using switch statement?

#include<stdio.h>

#include<conio.h>

void main()

{ int n;

printf("please enter number \n");

scanf("%d",n);

switch(n%2)

{

case 0 : printf("even");

break;

case 1 :

case -1 :

printf("odd");

}

getch();

}

Write a program to find all triad numbers below 1000 where the second number is twice the first and the third is three times the first number?

#include

#include

int main()

{

int i,j,k,l,m,n,p,q,temp,fno,secno,thirdno;

int arr[1][9];

cout<<"---------------------------------------ABRAR TARIQ-------------------------------"<

cout<<"Here are the all possible combinations of the triad numbers between 1 to 1000 ! cheers !"<

int a=0;

for(i=100;i<=1000;i++)

{

for(j=i+1;j<=1000;j++)

{

if(j==2*i)

{

fno=i;

secno=j;

}

if(j==3*i)

{

thirdno=3*i;

}

}

k=fno/100;

temp=fno%100;

l=temp/10;

m=temp%10;

arr[0][0]=k;

arr[0][1]=l;

arr[0][2]=m;

k=secno/100;

temp=secno%100;

l=temp/10;

m=temp%10;

arr[0][3]=k;

arr[0][4]=l;

arr[0][5]=m;

k=thirdno/100;

temp=thirdno%100;

l=temp/10;

m=temp%10;

arr[0][6]=k;

arr[0][7]=l;

arr[0][8]=m;

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

{

for(p=0;p<9;p++)

{

for(q=p+1;q<9;q++)

{

if(arr[n][p]==arr[n][q]arr[n][p]==0arr[n][q]==0)

{

a=1;

}

if(a==1)

break;

}

if(a==1)

{

a=0;

break;

}

}

if(p==9&&q==9&&a==0)

{

cout<<<","<<<","<<<

cout<<"---And---"<

}

}

return 0;

}

Storage pool in datastructure?

Storage pool is collection of free linked list in the memory.

What is compared with the value that follows each of the case statements when a switch statement executes?

The expression in the switch statement is evaluated. The result of this evaluation is then compared with each case statement in turn until a matching case is found, which then forces a jump to the appropriate case. Execution then continues from that point until a break, return or goto statement is encountered, or execution falls through the switch statement.

What is the maximum length allowed in difining a c variable?

In order to claim compliance with ANSI C standards, the minimum maximum for internal identifiers and macros is 63 characters, and external identifiers is 31 characters. Vendors are encouraged to avoid imposing a maximum value whenever possible.

What is a GCD?

GCD stands for the Greatest Common Denominator.

No it doesn't. GCD is the greatest common divisor, also known as the greatest common factor.

The greatest common Denominator dne.

Find the highest and lowest element from a linked list?

To find the highest and lowest elements in a linked list, iterate the list and detect the highest and lowest elements. Details omitted ...

list *head; /* pointer to first element */

list *temp; /* temp pointer

list *high = null; /* pointer to high element */

list *low = null; /* pointer to low element */

for (temp=head; temp!=null; temp=temp->next) { /* iterate all elements */

if (temp == head ) { /* initial case */

high = low = temp; /* start accumulating results

} else { /* otherwise */

if (higher(temp, high) high = temp; /* choose higher */

if (lower(temp, low) low = temp; /* choose lower */

}

}

Write a c program to find the product of two numbers without using operator?

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,multi;

clrscr();

printf("enter a value for a and b");

scanf("%d%d",&a,&b);

multi=a*b;

printf("the result is %d", multi);

getch()

}

How do you input float into an array?

#include

using std::cin;
using std::cout;
using std::endl;

int main()
{
int myArraySize = 10;
//array of type float declaration and initialization of all elements to zero
float myArray[myArraySize] = {0.0f};

cout << endl << "Enter element of your array (of type float)..." << endl;
for(int i(0); i < myArraySize; i++)
{
cout << endl << "Enter " << (i + 1) << " element: ";
cin >> myArray[i];

}

cout << endl << "You have entered: " << endl;
for(int i(0); i < myArraySize; i++)
{
cout << (i + 1) << " element: " << myArray[i];

}

system("PAUSE");
return 0;

}

Write any small program that will compile in C but not in C plus plus?

#include

int main (void)

{

char new [3] = "NEW";

printf ("new='%.3s'\n", new);

return 0;

}

in C++:

int main (void)

{

char newstr [4] = "NEW";

printf ("new='%.3s'\n", newstr);

return 0;

}

How is the old stack pointer value recovered on a function return?

If your stack grows bottom-up, it's decremented when you leave a function; if the stack grows top-down, the stack pointer is incremented.

To evaluate a variable you must values for the variable and then calculate the result?

No. To evaluate a variable, you simply take its value. When you assign a value to a variable, the evaluation of that operation is the value of the variable after assignment. There is no calculation required to evaluate a variable, unless that calculation is part of the right-hand operand of an assignment operation, in which case the calculation is evaluated first and the result of that evaluation (the value) is then assigned to the variable which is then evaluated.

Describe a chicken using a programming language?

chicken is a function which takes argument as grain type and returns egg.

egg chicken(grain x);

How much height to loop the loop?

The height of the loop depends on the entry speed The diameter is usually adjusted to provide 1g acceleration in the upward direction to the upside-down passengers.

Technically, if the entry speed is the variable, and you don't worry about smashing the passengers or the g-forces, the loop can be ANY size.

Flow chart of LCM?

See the related links posted below.

It is a good example of calculating the Least Common Multiplier.

Write a c program for binary searching?

/* C program for binary search: This code implements binary search in */

/* C language. It can only be used for sorted arrays, but it's fast as */

/* compared to linear search. If you wish to use binary search on an */

/* array which is not sorted then you must sort it using some sorting */

/* technique say merge sort and then use binary search algorithm to */

/* find the desired element in the list. If the element to be searched */

/* is found then its position is printed. */

#include<stdio.h>

main()

{

int c, first, last, middle, n, search, array[100];

printf("Enter number of elements\n");

scanf("%d",&n);

printf("Enter %d integers\n", n);

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

scanf("%d",&array[c]);

printf("Enter value to find\n");

scanf("%d",&search);

first = 0;

last = n - 1;

middle = (first+last)/2;

while( first <= last )

{

if ( array[middle] < search )

first = middle + 1;

else if ( array[middle] == search )

{

printf("%d found at location %d.\n", search, middle+1);

break;

}

else

last = middle - 1;

middle = (first + last)/2;

}

if ( first > last )

printf("Not found! %d is not present in the list.\n", search);

return 0;

}

What is a variable that accumulates the sum of several numbers?

A total is a variable that accumulates the sum of several numbers.

Answer is based on C How to Program (6th Edition)