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

Can you stack enemy buffizers in mother 3?

In Mother 3, stacking enemy buffizers does not result in cumulative buffs. When multiple buffizers use their abilities, only the strongest effect applies, meaning that if a new buff is applied, it will override the previous one instead of enhancing it further. This mechanic encourages players to strategize around the timing and order of enemy actions rather than relying on stacking buffs for a more significant advantage.

What Bytes occupied by double data type in c?

The number of bytes occupied by a specific data type depends on the implementation. In general, the double data type is eight bytes long, but you can check it using sizeof(double). In 16-bit,32-bit compilers double size is

8 bytes.It looks like float because it stores scientific and financial like big float values.

Write a recursive function to find sum of even numbers from 2 to 150?

int sum (int from, int to, int step)
{
if (from>to) return 0;
else return from + sum (from+step, to, step);

}

...

n = sum (2, 150, 2);

Why are the statements in the body of a loop called conditionally executed statements?

These statements are called conditionally executed statements because the may or may not be executed. They will be executed while the boolean (true/false) statement in the beginning of the loop is true, but will not be executed when statement is false.

What is SYNTAX of malloc and calloc in C language?

int *p = (int*) malloc (n*sizeof(int*));

where n is the number of units you wish to allocate.

Always remember to check the result of a malloc operation before continuing to avoid issues arising from lack of available memory. For example,

if (p!=NULL)

... // code segment

C programming diamond shape for loops Problem and output sample is in the picture?

#include<stdio.h>

main()

{

int i;

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

{

printf("*",i);

}

printf("\n");

for(i=1;i<=3;i++)

{

printf("*",i);

}

printf("\n");

for(i=1;i<=5;i++)

{

printf("*",i);

}

printf("\n");

for(i=1;i<=3;i++)

{

printf("*",i);

}

printf("\n");

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

{

printf("*",i);

}

}

Write a program of 6-digits num and print that as series of digits and each digit is print on one line?

#include

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

int main()
{
string myNumber = "0";
cout << endl << "Enter a 6-digit number: ";
cin >> myNumber;

cout << endl << "You've entered: " << myNumber << endl;

for (int i = 0; i < myNumber/myNumber[0]; i++)
{
cout << endl << (i + 1) << " element is " << myNumber[i];
}


cout << endl;

system("PAUSE");
return 0;

}

Matrix chain multiplication program using C?

# include <stdio.h>

# include <conio.h>

# include <stdlib.h>

# define sz 20

# define INF 200000

void print(unsigned long s[][sz], int i, int j)

{

if (i == j)

printf(" A%d ",i);

else

{

printf(" ( ");

print(s, i, s[i][j]);

print(s, s[i][j] + 1, j);

printf(" ) ");

}

}

void printm(unsigned long m[][sz], int n)

{

int i,j;

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

{

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

{

printf("%5d",m[i][j]);

}

printf("\n\n");

}

printf("\nThe No. of multiplication required is : %d",m[1][n]);

}

void Matrix_Chain_Order(int p[],int num)

{

unsigned long m[sz][sz] = {0};

unsigned long s[sz][sz] = {0};

unsigned int q = 0;

int i, j, k, l;

int n = num;

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

m[i][i] = 0;

for(l = 2; l <= n; l++)

for(i = 1; i <= (n - l + 1); i++)

{

j = i + l - 1;

m[i][j] = INF;

for(k = i; k <= j - 1; k++)

{

q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];

if(q < m[i][j])

{

m[i][j] = q;

s[i][j] = k;

}

}

}

print(s, i-1, j);

printf("\n\n");

printf("The Minimum No. of Multiplication Required is:\n\n");

printm(m,n);

}

void main()

{

int i,num=0,p[sz]={0};

clrscr();

printf("Enter the number of matrix : ");

scanf("%d",&num);

printf("Enter %d no. of order sequence for %d matrix :\n",num+1,num);

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

scanf("%d",&p[i]);

printf("\n\n");

printf("MULTIPLICATION SEQUENCE IS : ");

printf("\n\n\t");

Matrix_Chain_Order(p,num);

getch();

}

Write a program to copy the contents of one array into another in the reverse order?

do something like this

char[] myArr = {'a','b'};

StringBuilder sb = new StringBuilder();

sb.reverse();

char[] charArr = sb.toString().toCharArray();

or something like this

char[] charArr = new char[myarr.length];

for (int i=myarr.length-1,j=0;i>=0;i++,j++){

charArr[j] = myarr[i];

}

In c plus plus are local declarations visible to the function in a program?

If you declare a variable inside of any fuction (except main) it will not be available to other functions.

What is the optional in a variable declaration statement?

Optional is the assignment of the value of course.

int number; //Variable Declaration
int number=2; //Assignment Declaration

How do you convert polar to rectangular coordinates?

If the polar coordinates of a point P are (r,a) then

the rectangular coordinates of P are x = rcos(a) and y = rsin(a).

What is it called when you write a number as a sum?

sum= answer of an addition question.. so the number of the sum is the answer.

Write a function which takes your text as an input and print it in a center of the box in c plus plus?

C++ has no generic graphics capability whatsoever. Graphics are platform-specific, and every C++ implementation provides its own API and libraries specific to the intended platform.

For instance, the following user-defined Visual C++ MFC function will centre any text (t) within a given rectangle (r) relative to the given device context (dc):

void centre_text(CString& t, CRect& r, CDC& dc)

{

CRect b; // bounding rectangle.

// Calculate the bounding rectangle of the text:

dc.DrawText( t, b, DT_CALCRECT );

// Position the bounding rectangle in the centre of the given rectangle:

b.MoveToXY(

r.left + (( r.Width() - b.Width() ) / 2 ),

r.top + (( r.Height() - b.Height() ) / 2 ));

// Draw the text in the bounding rectangle:

dc.DrawText( t, b, DT_NOCLIP );

}

Note that the above code is non-generic and therefore cannot be ported to other platforms. It will only work in Visual C++ MFC applications. However, the principal will be largely the same on other platforms: calculate the bounding rectangle, move it to the centre of the intended rectangle and then print the text in the bounding rectangle.

How do you enter a number in bits?

I assume you mean a binary representation of a number.
The "least significant bit" (usually the one to the far right but in some languages it has another placement) is "ones"
the next most significant bit are the twos
The third most significant bit are the fours
etc.

So if your number is 37
there is one 32 (the sixth most significant bit)
no 16's (the fifth most significant bit)
no 8's (the fourth most significant bit)
one 4 (the third most significant bit)
no 2's (the second most significant bit)
one 1 (the least most significant bit)

if we are to fill an 8 bit "word " we get:
0010 0101

How do you create a text file?

If you have Notebook, then you just have to type your stuff there and they will be automatically will be saved as aText Document.

What are bare output conditions in minimalist syntax?

As far as my knowledge predicts, Bare Output Conditions (or Legibility Conditions) are a set of well-formedness conditions that hold at PF & LF interfaces. These conditions were proposed by Chomsky Noam in his Strong Minimalist Thesis " language is the optimal solution to legibility conditions" in Minimalist Program 1993. They include:

_Full interpretation

_Theta Criterion

_Convergence ...etc