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 do you convert Dotted Decimal 121.55.7.15 to Binary?

Each number separated by a dot is an eight bit number, so conversion requires converting four numbers. To convert a decimal number to binary, divide by two in succession until the number zero is reached.

121 / 2 = 60 r 1

60 / 2 = 30 r 0

30 / 2 = 15 r 0

15 / 2 = 7 r 1

7 / 2 = 3 r 1

3 / 2 = 1 r 1

1 / 2 = 0 r 1

Then, you read remainders backwards:

1111001

If there's less than 8 numbers, add zeroes to the left:

01111001

Then, do this for the other numbers.

55 / 2 = 22 r 1

22 / 2 = 11 r 0

11 / 2 = 5 r 1

5 / 2 = 2 r 1

2 / 2 = 1 r 0

1 / 2 = 0 r 1

00101101

7 / 2 = 3 r 1

3 / 2 = 1 r 1

1 / 2 = 0 r 1

00000111

15 / 2 = 7 r 1

7 / 2 = 3 r 1

3 / 2 = 1 r 1

1 / 2 = 1 r 1

00001111

Once you have all the binary digits, simply stick them back together using dots:

01111001.00101101.00000111.00001111

How do you type c with accent?

Use charmap.exe, (you can use these characters: ĆĈĊČ, and many others)

What is the difference between 'while' and 'when'?

What is asking about something -- what is your name

When is asking about time date -- when were you born

I have left the question marks(?) off the questions because Wiki answers doesn't like answers with questions

Example of ATM programing by turbo c?

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<stdlib.h>

#define pf printf

#define s scanf

int gd=DETECT, gm, pa, o, b;

int i;

int x, y, i,ch,c;

int c, m, p, qn, cm, mp, cp, cmp, n, k, p1, g,qcm,qmp,qcp,qc,qm,qp;

void main()

{

initgraph(&gd,&gm," ");

cleardevice();

line(0,0,639,0);

line(0,0,0,479);

line(639,0,639,479);

line(639,479,0,479);

line(589,479,0,479);

randomize();

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

{

setcolor(i);

x=rand()%639;

y=rand()%480;

putpixel

(x,y,i);

{

setcolor(RED);

settextstyle(3,0,5);

outtextxy(60,100, "PROJECT IN DISCRETE");

setcolor(RED);

settextstyle(3,0,5);

outtextxy(80,135, "MATHEMATICS");

setcolor(i);

settextstyle(2,0,5);

outtextxy(120,192,"SUBMITTED BY :");

setcolor(i);

settextstyle(2,0,5);

outtextxy(120,202,"Cabrera");

setcolor(i);

settextstyle(2,0,5);

outtextxy(120,214,"Gaspar");

setcolor(i);

settextstyle(2,0,5);

outtextxy(120,226,"Molina");

setcolor(i);

settextstyle(2,0,5);

outtextxy(120,238,"Viray");

}

setcolor(i);

settextstyle(2,0,5);

outtextxy(400,350,"U P L O A D i N G...");

setcolor(WHITE);

outtextxy(i,378,"=");

outtextxy(i,406,"=");

setcolor(WHITE);

circle(i,400,10);

delay(1);

}

cleardevice();

gotoxy(10,7);

pf("Enter 1 for V E N N D I A G R A M ");

gotoxy(10,8);

pf("Enter 2 for S E T N O T A T I O N");

gotoxy(10,10);

printf("Input: ");

s("%d",&pa);

cleardevice();

{

if(pa==1)

{ {

line(0,0,639,0);

line(0,0,0,479);

line(639,0,639,479);

line(639,479,0,479);

line(589,479,0,479);

randomize();

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

{

setcolor(i);

x=rand()%639;

y=rand()%480;

putpixel

(x,y,i);

{

setcolor(i);

settextstyle(9,0,5);

outtextxy(60,100, "V E N N");

setcolor(i);

settextstyle(9,0,5);

outtextxy(80,165, "D I A G R A M");

}

setcolor(i);

settextstyle(2,0,5);

outtextxy(400,350,"U P L O A D i N G...");

setcolor(YELLOW);

outtextxy(i,378,"=");

outtextxy(i,406,"=");

setcolor(WHITE);

circle(i,400,10);

delay(1);

}

sleep(1);

cleardevice();

}

gotoxy(10,7);

pf("Enter 1 if the Outside is missing. 3 Circle. ");

gotoxy(10,8);

pf("Enter 2 if the Total is missing. 3 Circle.");

gotoxy(10,11);

printf("Choice : ");

s("%d",&p1);

for(g=1;g<=8;g++)

{ if(p1==1)

{

cleardevice();

gotoxy(32,8);

pf("Input the Values for the following variables:");

gotoxy(32,11);

pf("X:");

gotoxy(32,12);

pf("Y:");

gotoxy(32,13);

pf("Z:");

gotoxy(32,14);

pf("XY:");

gotoxy(32,15);

pf("XZ:");

gotoxy(32,16);

pf("YZ:");

gotoxy(32,17);

pf("XYZ:");

gotoxy(32,18);

pf("Outside:");

gotoxy(32,19);

pf("Total Number:");

{

if(g==1){gotoxy(42,18);pf("----");gotoxy(42,11);s("%d",&c);}

if(g==2){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);s("%d",&m);}

if(g==3){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);s("%d",&p);}

if(g==4){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);scanf("%d",&cm);}

if(g==5){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);s("%d",&cp);}

if(g==6){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);pf("%d",cp);gotoxy(42,16);s("%d",&mp);}

if(g==7){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);pf("%d",cp);gotoxy(42,16);pf("%d",mp);gotoxy(42,17);s("%d",&cmp);}

if(g==8){gotoxy(42,18);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);pf("%d",cp);gotoxy(42,16);pf("%d",mp);gotoxy(42,17);pf("%d",cmp);gotoxy(50,19);s("%d",&k);}

cleardevice();

}}

{ qcm=cm-cmp;

qmp=mp-cmp;

qcp=cp-cmp;

qc=c-(qcp+cmp+qcm);

qm=m-(qcm+cmp+qmp);

qp=p-(qcp+cmp+qmp);

qn=k-(cmp+qcp+qcm+qmp+qc+qm+qp);

}

cleardevice();

setcolor(RED);

rectangle(600,450,40,40);

setcolor(YELLOW);

circle(250,200,125);

setcolor(GREEN);

circle(375,200,125);

setcolor(BLUE);

circle(313,300,125);

gotoxy(39,15);

printf("%d",cmp);

gotoxy(30,4);

printf("X");

gotoxy(49,4);

printf("Y");

gotoxy(23,12);

printf("%d",qc);

gotoxy(55,12);

printf("%d",qm);

gotoxy(39,23);

printf("%d",qp);

gotoxy(39,9);

printf("%d",qcm);

gotoxy(30,18);

printf("%d",qcp);

gotoxy(49,18);

printf("%d",qmp);

gotoxy(63,25);

printf("%d",qn);

gotoxy(39,27);

setcolor(WHITE);

outtextxy(310,435,"Z");

}

for(g=1;g<=8;g++)

{

if(p1==2)

{cleardevice();

gotoxy(32,8);

pf("Input the Values for the following variables:");

gotoxy(32,11);

pf("X:");

gotoxy(32,12);

pf("Y:");

gotoxy(32,13);

pf("Z:");

gotoxy(32,14);

pf("XY:");

gotoxy(32,15);

pf("XZ:");

gotoxy(32,16);

pf("YZ:");

gotoxy(32,17);

pf("XYZ:");

gotoxy(32,18);

pf("Outside:");

gotoxy(32,19);

pf("Total Number:");

{

if(g==1){gotoxy(42,19);pf("----");gotoxy(42,11);s("%d",&c);}

if(g==2){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);s("%d",&m);}

if(g==3){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);s("%d",&p);}

if(g==4){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);scanf("%d",&cm);}

if(g==5){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);s("%d",&cp);}

if(g==6){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);pf("%d",cp);gotoxy(42,16);s("%d",&mp);}

if(g==7){gotoxy(42,19);pf("----");gotoxy(42,11);pf("%d",c);gotoxy(42,12);pf("%d",m);gotoxy(42,13);pf("%d",p);gotoxy(42,14);pf("%d",cm);gotoxy(42,15);pf("%d",cp);gotoxy(42,16);pf("%d",mp);gotoxy(42,17);pf("%d",cmp);gotoxy(42,18);s("%d",&n);}

cleardevice();

}}

{ qcm=cm-cmp;

qmp=mp-cmp;

qcp=cp-cmp;

qc=c-(qcp+cmp+qcm);

qm=m-(qcm+cmp+qmp);

qp=p-(qcp+cmp+qmp);

qn=k-(cmp+qcp+qcm+qmp+qc+qm+qp);

}

cleardevice();

setcolor(RED);

rectangle(600,450,40,40);

setcolor(YELLOW);

circle(250,200,125);

setcolor(GREEN);

circle(375,200,125);

setcolor(BLUE);

circle(313,300,125);

gotoxy(39,15);

printf("%d",cmp);

gotoxy(30,4);

printf("X");

gotoxy(49,4);

printf("Y");

gotoxy(23,12);

printf("%d",qc);

gotoxy(55,12);

printf("%d",qm);

gotoxy(39,23);

printf("%d",qp);

gotoxy(39,9);

printf("%d",qcm);

gotoxy(30,18);

printf("%d",qcp);

gotoxy(49,18);

printf("%d",qmp);

gotoxy(63,25);

printf("%d",qn);

gotoxy(39,27);

setcolor(WHITE);

outtextxy(310,435,"Z");

}

}

getche();

}

{

if(pa==2)

{

{

line(0,0,639,0);

line(0,0,0,479);

line(639,0,639,479);

line(639,479,0,479);

line(589,479,0,479);

randomize();

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

{

setcolor(i);

x=rand()%639;

y=rand()%480;

putpixel

(x,y,i);

{

setcolor(i);

settextstyle(9,0,5);

outtextxy(60,100, "S E T");

setcolor(i);

settextstyle(9,0,5);

outtextxy(50,165, "N O T A T I O N");

}

setcolor(i);

settextstyle(2,0,5);

outtextxy(400,350,"U P L O A D i N G...");

setcolor(YELLOW);

outtextxy(i,378,"=");

outtextxy(i,406,"=");

setcolor(WHITE);

circle(i,400,10);

delay(1);

}

sleep(1);

cleardevice();

}

printf("ogi");

getche();

}

}

cleardevice();

gotoxy(10,10);

printf("--END--");

getche();

}

Can you perform insertion and deletion in an array?

You can, but it's not as straightforward as inserting or deleting from a list. This is simply because arrays are not intended for insertions or deletions other than at the end of the array. This is because an insertion requires that the entire array be reallocated (which may require the array to be copied in its entirety) simply in order to make room for the new element, which can then simply be inserted in the unused element at the end of the new array. To insert elsewhere in the array, all the elements following the insertion point need to be copied (for a second time) into the next element, starting with the last used element. the entire process can prove quite costly, especially if the elements are complex objects which would require their copy constructors to be invoked at least once and possibly twice. This is why it is generally better to use arrays of pointers to objects rather than arrays of objects, as copying a pointer is more efficient than copying an object. However, if your array undergoes frequent resizing in order to accommodate insertions and deletions, then you really would be better off using a list.

To avoid making a definite statement?

One can use language that expresses uncertainty or possibility, such as using words like "may," "might," "could," or "potential." By using these types of words, it allows for flexibility and avoids making a definitive statement. Additionally, using conditional language like "if," "unless," or "depending on" can also help to avoid making a definite statement.

How do you use logic inside switch statement?

Nothing special, eg:

switch (c) {

case 'A':

/* use any 'logic' you want */

break;

default:

/* use any 'logic' you want */

}

What is a loop tool?

A loop tool is used to smooth and model clay into shape. The tool has a wooden handle and a metal loop at the end that can come in different sizes.

What is difference between conditional operator and bitwise operator?

A binary operator is simply an operator that has two parts, written to the left and to the right of the operator, e.g.:

1 + 2

The binary operator can be a logical operator ("and", "or", "xor", etc. - but "not" is a unary operator), or it can be in some other category, like the arithmetic operator shown above.

A binary operator is simply an operator that has two parts, written to the left and to the right of the operator, e.g.:

1 + 2

The binary operator can be a logical operator ("and", "or", "xor", etc. - but "not" is a unary operator), or it can be in some other category, like the arithmetic operator shown above.

A binary operator is simply an operator that has two parts, written to the left and to the right of the operator, e.g.:

1 + 2

The binary operator can be a logical operator ("and", "or", "xor", etc. - but "not" is a unary operator), or it can be in some other category, like the arithmetic operator shown above.

A binary operator is simply an operator that has two parts, written to the left and to the right of the operator, e.g.:

1 + 2

The binary operator can be a logical operator ("and", "or", "xor", etc. - but "not" is a unary operator), or it can be in some other category, like the arithmetic operator shown above.

What is the use of time.h in c?

The time.h include file is a header file for a library of standard time and date manipulation routines. For example...

#include <stdio.h>

#include <time.h>

int main (int argc, char ** argv) {

time_t tt = time(NULL);

printf ("The date and time is %s", asctime(localtime(&tt)));

return 0;

}

TCS230 sensor code in embedded c?

i dont know please give some idea to develope in sensor coding

Why do you use hashing and not array?

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

Hashing provides a method to search for data.

What is meant by the following statement A repeater is limited not only in function but also in scope?

A repeater contains one input port and one output port, so it is capable only of receiving and repeating a data stream.

Addition of matrix using arrays in c?

#include<stdio.h>

int main(){

int a[3][3],b[3][3],c[3][3],i,j;

printf("Enter the First matrix->");

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

for(j=0;j<3;j++)

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

printf("\nEnter the Second matrix->");

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

for(j=0;j<3;j++)

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

printf("\nThe First matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",a[i][j]);

}

printf("\nThe Second matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",b[i][j]);

}

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

for(j=0;j<3;j++)

c[i][j]=a[i][j]+b[i][j];

printf("\nThe Addition of two matrix is\n");

for(i=0;i<3;i++){

printf("\n");

for(j=0;j<3;j++)

printf("%d\t",c[i][j]);

}

return 0;

}

What are the four file commands to read and write to a file?

Please refine your question, it is not precise enough to get a clear understanding of what you are asking.

What will be the prototype of a user defined function?

In C programming, there are no built-in functions; all functions are user-defined. In order to use a function it must first be declared. This can be achieved by importing the header file containing the declaration (via the #include compiler directive) or by typing the declaration by hand.

The definition (implementation) of a function is not required in order to use a function, but if a function is used it has to be defined somewhere (undefined functions will cause a link error). Where a function is used by several translation units, placing the declaration in a header file ensures the declaration is consistent across all translation units. Grouping declarations by purpose allows us to import several declarations at once. Declarations that are not used are simply ignored.

A declaration informs the compiler of the function's name and type, and the number and type of its arguments, if any. This describes the interface to the function. A function's type is denoted by its return type. A function that has no return value is simply declared void (no type). The return type always comes first in a declaration, followed by the function name, which must be a unique identifier within the scope in which it is declared (global or local scope). A local name will mask a global name, effectively hiding it from the local scope.

Function arguments (the formal arguments of the function) are delimited by parenthesis after the function name. A single argument of type void denotes no arguments while multiple argument types must be separated by commas (void types are not permitted in a multiple argument function). The complete declaration is terminated by a semi-colon immediately after the closing parenthesis. If the declaration is also a definition, the function body (the implementation) replaces the closing semi-colon.

To assist with documentation, the formal arguments of a declaration may be named (unless the argument is void). However, where names are given, they need not match the corresponding names provided by a function's definition, where defined separately. Using longer descriptive names in the declaration helps document their purpose, while the definition can use shorter names that are easier to work with.