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

Who is the inverter of c-language?

I think you mean "inventor". There were two: Dennis Ritchie and Ken Thompson.

Is it possible to change the data type for a field that already contains data?

You can change the data type of an existing field using a union, however, you should understand that bit format dependance is not portable usage, and that you should initialize the field every time you change your desired type.

Answer: without specifying the context, this question cannot be answered.

What is the meaning of LS in programming?

Such short abbreviations normally mean several things. One meaning of "ls" is the command used in UNIX and Linux to show a list of files. This is basically the equivalent of the DOS/windows "dir" command.

What are the basic component parts of a 'C' program and how are they structured in a 'C' source program fileWhat is Source Program and Object Program?

The basic components are datatypes and functions. There must always be at least one function, the main function. This function implements the entry point of the application, and is typically used to process and act upon command-line arguments. Although you may write all your code within that one function, this is only suitable for trivial programs. More complex programs are best broken down into a series of smaller functions that can be called and re-called as required. For the most complex programs, functions and datatypes are best placed in separate files, grouped by purpose. This makes code easier to maintain but also makes code easier to re-use within other programs by modularising the component parts.

A source program -- or source code -- is the code that you, the programmer, write. The source code is usually written in a high level language but can also be written in a low level language, or even a combination of the two. The lower the level, the less abstraction there is between the source code and the resultant machine code. Although C is a high-level language, its flexibility allows programming at a procedural level, where the C instructions can be mapped very closely with the resultant machine code. Thus it is often classed a low level language. In reality it provides the best of both worlds, thus it is correctly termed a mid-level language. Since C++ inherits from C, it has similar properties. However C++ encourages the use of high-level object-oriented programming which makes it easier to produce and maintain more complex structured programs more easily than with C-style programming alone.

Object programs are the machine code files that are produced from your source code. Object programs should not be confused with "objects" as employed in the object-oriented programming paradigm (where an object is an instance of a class). In C, compiling your source code produces one or more object files which are subsequently linked to produce the final executable, the object program. By modularising your source code, compilation times can be greatly reduced since only those object files that are affected by modifications to the source code need be recompiled.

To write a c program that counts number of blanks in a text file using standard io in unix?

#include<sys/types.h>

#include<sys/stat.h>

#include<unistd.h>

#include<fcntl.h>

#include<stdio.h>

int main()

{

char str[100]="abc d e f gh";

int c=0;

int fd,n,i;

n=strlen(str);

fd=create("multiple.c",O_WRONLY);

write(fd,str,n);

close(fd);

printf("file created /n");

fd=open("multiple.c",O_RDONLY);

read(fd,str,n);

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

{

if ( str[i] == ' ' )

c++;

}

printf("no of spaces =%d",c);

}

What is the basic cocept of RDMBS?

RBMBS stands for "relational database management systems" A very basic concept is: a system for collectingpieces of information about a person or entity or even a product that allows for a sensible and or logical presentation at will, different forms or structure for a particular purpose. For example a telephone directory of names and individuals listing is a relational database. The phone directory like the white pages that we normally use is one form ofa database.Another form of the same database thatis used by an emergency agency or police department, (the so called reverse directory) is a database of the sameinformation but listed with the number first instead of the name of the person.

Did linker converts source program into machine code?

No.That's the job of the compiler. The linker takes the pieces of object code created by the compiler and links all the necessary pieces together to produce a finished product: either an executable program or a code library that can be used in future projects.

What is the difference between header files and namespace in cpp?

Header files are actual files - stored in the file system, referenced by file name, and #include'd in other files (at least, in C/C++ or other languages using the M4 macro preprocessor). Header files typically group pieces of code that are all interdependent parts of the same specific item together. For instance, a game might have a header file for all of its graphics rendering.

Namespaces, on the other hand, are an element of the programming language - they don't exist as a file system object, but rather as a designation within code telling the compiler that certain things are within that namespace. Namespaces typically group interfaces (functions, classes/structs, types) of similar (but not necessarily interdependent) items. For instance, the std namespace in C++ contains all of the Standard Library functions and classes.

How do you make a message box in c plus plus?

#include<windows.h>

int main()

{

MessageBox(0,"Hello","Welcome Message",1);

return 0;

}

Write a program to represent a polynomial as linked list and write functions for polynimial addition?

#include<iostream.h> #include<stdlib.h> #include<conio.h> struct poly { int coeff; int x; int y; int z; struct poly * next; }; class polynomial { private : poly *head; public: polynomial():head(NULL) { } void getdata(); void display(); void insert(poly *prv,poly *curr,poly *p); polynomial operator + (polynomial ); }; polynomial polynomial :: operator +(polynomial px2) { polynomial px; poly *t1,*t2,*t3,*last; t1 = head; t2 = px2.head; px.head = NULL; while(t1 != NULL && t2 != NULL) { t3 = new poly; t3->next = NULL; if(t1->x t2->z) { t3->coeff = t1->coeff + t2->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; t2 = t2->next; } elseif(t1->x > t2->x) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->x < t2->x) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } elseif(t1->y > t2->y) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->y < t2->y) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } elseif(t1->z > t2->z) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->z < t2->z) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } if(px.head == NULL) px.head = t3; else last->next = t3; last = t3; } if(t1 == NULL) t3->next = t2; else t3->next = t1; return px; } void polynomial :: insert(poly *prv,poly *curr,poly *node) { if(node->x curr->z) { curr->coeff += node->coeff; delete node; } elseif((node->x > curr->x) (node->x curr->y && node->z > curr->z)) { node->next = curr; prv->next = node; } else { prv = curr; curr = curr->next; if(curr == NULL) { prv->next = node; node->next = NULL; return; } insert(prv,curr,node); } return; } void polynomial :: getdata() { int tempcoeff; poly *node; while(1) { cout << endl << "Coefficient : "; cin >> tempcoeff; if (tempcoeff==0) break; node = new poly; node->coeff = tempcoeff; cout << endl << "Power of X : "; cin >> node->x; cout << endl << "Power of Y : "; cin >> node->y; cout << endl << "Power of Z : "; cin >> node->z; if(head == NULL) { node->next = NULL; head = node; } elseif(node->x head->z) { head->coeff += node->coeff; delete node; } elseif((node->x > head->x) (node->x head->y && node->z > head->z)) { node->next = head; head = node; } elseif (head->next == NULL) { head->next = node; node->next = NULL; } else insert(head,head->next,node); } } void polynomial :: display() { poly *temp; temp = head; cout << endl << "Polynomial :: "; while(temp != NULL) { if(temp->coeff < 0) cout << " - "; cout << abs(temp->coeff); if(temp->x != 0) cout << "x^" << temp->x; if(temp->y != 0) cout << "y^" << temp->y; if(temp->z != 0) cout << "z^" << temp->z; if(temp->next->coeff > 0) cout << " + "; temp = temp->next; } cout << " = 0"; } void main() { polynomial px1,px2,px3; clrscr(); px1.getdata(); px2.getdata(); px3 = px1 + px2; px1.display(); px2.display(); px3.display(); getch(); }

What is the difference between business function and management function?

Functions of Management are

planning: planning premises; types of plan; planning process; organizing: span of control and organizational structure, line and staff functions and conflicts; centralization and decentralization; delegation; staffing: manpower planning, recruitment, selection and placemen; induction training; directing: principles of direction; coordinating, and controlling.

Wheras Business functions are Purchase,Production,Marketing,Finanace,HR,Operations.

REJI ISMAIL

reji.ismail786@gmail.com

Could array may have elements that are numbers and strings?

In Java:

Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.

In Java:

Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.

In Java:

Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.

In Java:

Not as primitives; but I believe you could create an array of Objects, and then initialize the elemnets as subtypes of the Object class, i.e., any class. I don't think this would be very practical (in Java); if (for example) you need to store information about people's names with their ages, create a class called "Person" that has those two attributes, then create an array of Persons.

How do you select pivot in quick sort?

quick sort has a best case time complexity of O(nlogn) and worst case time complexity of 0(n^2).

the best case occurs when the pivot element choosen as the center or close to the center element of the list.the time complexity can be derived for this case as:

t(n)=2*t(n/2)+n.

whereas the worst case time complexity for quick sort happens when the pivot element is towards the end of the list.the time complexity for this can be derived using the recurrence eqn:

t(n)=t(n-1)+n

How are the keywords struct and class different?

The keyword class is not a keyword in C. It is a keyword in C++, so I have added C++ to the category list for this question.

The default access specifier for struct is public, while for class, it is private.

Struct does not allow you to specify methods, while class does.

A struct is not a class, and cannot be derived, while a class can be treated as a struct, if the scope and access is correct.

Implimentation of pascle triangle in C?

#include
#include
void main()
{
int n,a=1,s=1,r;
printf("\n enter number of lines ");
cin>>n;

for(;a<=n;s=s*10+1)
{
for(b=n-a;b>=1;b--)
{
printf(" ");
}
r=pow(s,2);
printf("\n");
a++;
}

getch();
}// \m/

How many keywords are there in c?

answer:32 programme to print factorial of a given number in c languages

Whats the best laptop which can be used for a home entertainment as well as running high level programes such as VHDL?

Saying you need to run "high level programes such as VHDL" is sort of misleading. VHDL is simply a programming language for designing logic. You need to run the programs that simulate and/or compile the code that you've written.

To compose the code, any text editor will do. In that sense, the slowest machine that will let you edit text will work just fine.

To simulate or synthesize the code, the more complex your design, the more processing and memory power you'll need. For that, you'll need a mid to high end desktop computer or workstation. A good example is a well configured Hewlett Packard XW class workstation.

Of course, the computer that you choose, will depend on the software that you plan to use for simulation and/or synthesis. For windows workstations, I would recommend using Symphony EDA's VHDL Simili. It's available for free from their website.

Anyway, to make a long answer short, look for a computer with specs similar to the following:

* Hardware platform: PC with Intel Pentium II equivalent or better * Video: 1280x1024 resolution or higher (lower resolutions will work but not recommended) * 10/100 Network Card * Operating System: Windows XP and/or Red Hat Linux * Memory: Minimum of 512 MB of available RAM * Disk Space: Minimum 80GB + additional space for vendor libraries.

What is the difference between insertion sort and selection sort?

Both bubble sort and selection sort are in-place sorts, which means they require no additional space to sort. Both are O(n).

Both also share worst/average case time complexities of O(n2). Selection sort also has O(n2) for a best case scenario, while an intelligent bubble sort implementation will have O(n) for a best case (already sorted) scenario.

Note that while looking at the numbers above seem to show that bubble sort has a slight edge over selection sort, in practice you should choose selection over bubble. It will very nearly always perform better in real-time tests.

Write a c program to calculate the sum of the integer from 1 to 100?

#include<stdio.h>

#include<conio.h>

int main()

{

long int num,sum;

clrscr();

printf("ENTER ANY NUMBER\n");

scanf("%ld",&num);

sum=(num*(num+num))/2;

printf("Sum of the given range is %d",sum);

getch();

}

by dilkash

from MANUU.

for(int i=0;;i++)

{

i+=i;

}

///////but you have to write condition or the number to stop looping

Why is it bad to shine a laser pointer in a kiss concert?

Because, when Kiss performs, they fully embrace the identity of the "characters" they assume when they put on their makeup.

This includes Peter Criss, who assumes the inventory of a cat.

Have you ever seen what a cat does when it sees a laser pointer? At best, Peter Criss becomes very distracted and finds it difficult to drum. At worse, he spends half the show running around the stage trying to pounce on a shiny red dot.

What will change if you remove from your computer Microsoft silverlight?

You will not be able to see websites created with silverlight technology which is a big loose bacause only Microsoft uses it. But they also have same websites which can be seen without silverlight. So you loose nothing.