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 I improve my skills at the piano?

Not knowing what skill level you are, it is difficult to suggest any particular books, etc. BUT technical ability is what everyone needs to work on, so as painful as it may seem, you need to work scales (not necessarily from memory), arpeggios chords; so if you don't own a good scale book, go to a music store and you'll find one on your level. AND you should add to that some etude books; there again look and see what you can handle AND if you don't own a book of song material that you like, try Broadway of sacred, anything will do for that area.

AnswerThere is another school of thought on this question, and it is not just my passing thought. It is held by many piano educators. They hold that the best way to improve skills is within the context of the music you actually want to play. In other words, concentrate on making music, and do that by playing and practicing the music you want to play. Choose the music well, and practice technical difficulties as they present themselves in that music.

I'm not sure which approach I favor. I studied classical piano as a kid, and definitely the first answer was more like the approach I took. But, especially if you are not heading for a concert or recording career, I think I'd suggest that this music-based approach is better. Just play and practice the music you like.

As a follow-up, and regardless of the kind of music you play, You can improve almost anything you play by doing the following. Make the music 'more difficult to play' during your practice than it actually is. This is what I mean. Isolate a part of the music you want to improve. Say that it is a passage written all or mostly in eighth notes. Change the rhythmic pattern so that it is like dotted eighths/sixteenths. Practice it this way. Then change, if you can, so that the passage is played as sixteenths/eighths. This may be very tricky. Play it as slow as you have to in order to master it like this. Find other ways to change the passage. If your volume over a given line is uneven, then practice it unevenly. Yes, that is what I said. Practice it, for example, with the stresses in a given pattern: loud-soft-loud-soft-loud-soft. Then practice the same passage with the stresses switched: soft-loud-soft-loud. For a real challenge, mix the rhythm patterns and the volume patterns. Master it every way that you can dream up to change it. When you go back to playing it as written, not only will the passage be smoother, but it will feel, and it will be, easier. There are several other practice 'tricks' that you can use; good teachers can share some of them with you.

One important thing is that for every change you make to the music during practice, mix it up so that you are spreading the affect of the change over all the fingers as much as possible. This way you are spreading the work out to all the fingers, and this is how you repair habitual errors.

Even more important than that is to play music that you like, and to have a great time playing. I know how much pleasure piano playing can give over the course of a lifetime. Stay with it.

Assembly language pgm to find sum of n numbers?

C100 LXI H C200 21 ;

Load the HL register pair immediately

C101 00 ;

C102 C2 ;

C103 MOV B M 46 ;

Move the memory content

(Total number of

data)

in to B register

C104 MVI C 00 0E ;

Initialize

the

C register with 00

H

C

105 00 ;

C106 SUB A 97 ;

Clear the ac

cumulator

C107 INX H 23 ;

Increment the HL register pair (to get the

next

input data)

C108 MOV A M 7E ;

Move the memory content

in to

accumulator

C109 DCR B 05 ;

Decrement the B register

c

o

n

tent

C10A INX H 23 ;

Increment the HL register pair

C10B ADD M 86 ;

Add the memory content to

accumulator

C10C JNC C110 D2 ;

Jump if carry = 0, to C110

H

C10D 10 ;

C10E C1 ;

C10F INR C 0C ;

Increment the C register content

C110

DCR B 05 ;

Decrement the B register content

C111 JNZ C10A C2 ;

Jump if no zero to C10A

H

C112 0A ;

C113 C1 ;

C114 STA C300 32 ;

Store

the

accumulator content

(sum) at C300

H

C115 00 ;

C116 C3 ;

C117 MOV A C 79 ;

Move the C register content to accumulator

C118 STA C301 32 ;

Store

the

accumulator content

(

carry

) at C300

H

C119 01 ;

C11A C3 ;

C11B HL

T 76 ;

Halt the exection

Write a program in java to enter a String and convert all cat to dog?

import java.io.*;

class CatToDog

{

protected byte words(String xs)

{

byte a=0;

for(byte i=0;i<xs.length();i++)

{

if(xs.charAt(i)==' ')

a++;

}

return (byte)(a+1);

}

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

CatToDog o=new CatToDog();

System.out.print("Enter the String: ");

String s=in.readLine();

byte a=o.words(s),b=0,c=0;

String w[]=new String[a];

for(;b<a;b++)

w[b]="";

for(b=0;b<s.length();b++)

{

if(s.charAt(b)==' ')

c++;

else

w[c]+=s.charAt(b);

}

for(b=0;b<a;b++)

{

if(w[b].equalsIgnoreCase("Cat"))

System.out.print("Dog ");

else

System.out.print(w[b]+" ");

}

}}

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.

Who is the inverter of c-language?

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

Write a program to find the sum of squares of n natural numbers using c plus plus?

#include
#include
void main()
{
int sum_sqr(int n);
clrscr();
printf("%d",sum_sqr(5));//Sum of first 5 natural numbers' square values
getch();
}
int sum_sqr(int n)
{
int i,sum=0;
for(i=1;i<=n;i++)
{
sum=sum+(i*i);
}
return sum;
}

output:
55

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.

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.

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.

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 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 do you make a message box in c plus plus?

#include<windows.h>

int main()

{

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

return 0;

}

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

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(); }

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.