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 difference between C and C plus plus programming?

THE DIFFERENCE BETWEEN c&c++ IS JST THAT c++ IS MODIFIED LANGUAGE AND IT IS A HOGH LEVEL LANGUAGE AS COMPARED c IS A LOW LEVEL LANGUAGE

C++ was developed as a better 'C' language. In addition, C is a procedural language only, and C++ has both procedural language features and object oriented features.

Both are considered high level languages.

C++ is an addition to C. C only allows you to write programs as a list of instructions (procedure), while C++ allows you to write separate objects, and link them together to produce a piece of software.

What are the advantages and disadvantages of searching in C programming?

If the data is sorted and every element is directly accessible, then you can perform binary search (see built-in function bsearch), otherwise you have to do linear search (which is slower).

How do you declare a stack in c?

# #include

# #include

#

# const int TPILA=5; // TPILA es el valor maximo de elementos

# // que puede tener nuestra pila

#

# class PILA{

# public:

# int mipila[TPILA]; // Crea mi PILA de tamano TPILA

# int apilados; // Numero de objetos en LA PILA

# void reset(); // Vacia LA PILA

# void push(int v); // Agrega Valores en el tope de la PILA

# int pop(); // Retorna y elimina el tope de la PILA

# };

#

# void PILA::reset() // Vacia la PILA

# {

# apilados=0;

# }

#

# //Se Agrega(PUSH) un valor en el tope de la pila

# void PILA::push(int v)

# {

# // Comprueba que haya espacio dentro de la pila

# // para poder agregar el nuevo valor

# if(apilados

# {

# mipila[apilados++]=v;

# }

# }

#

# // Se Elimina (POP) el ultimo valor de la pila

# // y retorna el nuevo tope

# int PILA::pop()

# {

# if(apilados>0)

# {

# cout<<"El valor del tope eliminado era: ";

# // Retorna el valor del tope que fue eliminado

# return(mipila[--apilados]);

# }

# else

# cout<<"No existen datos para eliminar. ERROR ";

# return (0);

# }

#

# main()

# {

# PILA stack;

# stack.reset();

# int opc, i, dato;

# char out;

# do

# {

# do

# {

# clrscr();

# cout<<"El siguiente programa simula el funcionamiento de"<

# cout<<"una pila y es capaz de apilar un max. de 5 Valores"<

# cout<<"numericos enteros, para fines practicos\n\n";

# cout<<"Que operacion desea Realizar\n\n";

# cout<<"1.- Insertar un dato\n";

# cout<<"2.- Borrar un dato\n";

# cout<<"3.- Mostrar pila\n";

# cout<<"4.- Resetear Pila\n";

# cout<<"5.- Salir";

# cout<<"\n\n\nOpcion(1-5): ";

# cin>>opc;

# }

# while(opc>5);

#

# switch(opc)

# {

# case(1):

# if(stack.apilados

# {

# cout<<"dato?: ";

# cin>>dato;

# stack.push(dato);

# }

# else

# cout<<"ERROR! PILA LLENA!";

# cout<<"\n\nSalir?? (S/N): "; cin>>out;

# break;

# case(2):

# cout<

# cout<<"\n\nSalir?? (S/N): "; cin>>out;

# break;

# case(3):

# if(stack.apilados!=0)

# {

# cout<<"Los datos en la pila actualmente son: "<

# for(i=0;i

# { cout<

# }

# else

# cout<<"No existen datos en la pila"<

# cout<<"\n\nSalir?? (S/N): "; cin>>out;

# break;

# case(4):

# stack.reset();

# cout<<"\n\nSalir?? (S/N): "; cin>>out;

# break;

# case(5):

# out='s'; break;

# default:

# out='s'; break;

# }

# }

# while(out=='n' out=='N');

# }

What are the disadvantages of function in C?

In comparison to Strawberry Cheesecake, the main disadvantage of a function in C is that you can't eat it.

In comparison to a mature Brandy, the main disadvantage of a function in C is that you can neither smell nor drink it.

In comparison to functions in some, but not many, other programming languages, one limitation of functions in C is that they may not be nested: In C, a function definition cannot contain another function definition.

In comparison to some modern interpreted language, e.g. Python, one limitation of functions in C is that a function cannot generate another function.

What is the difference between a for loop and a while loop in java?

ComparisonThe conditions for both the 'while' and 'for' loop are exactly the same, but in each flow structure the conditions are placed in different locations. A 'for' loop places the full condition within the 'for' loop whereas the 'while' loop places the counter variable outside of the loop.

The 'for' loop is used when the length of the loop is known whereas the 'while' loop is usually used when the length of the loop is unknown.

'for' loop exampleWithin the parentheses the complete condition is contained. The condition has 3 parts delimited by a colon ';'. The first part sets the counter 'int i' to 0, the second part tells the loop to stop when the counter is 5. The third part tells java to increment the counter by 1 value each time the loop iterates.

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


'while' loop exampleWith the 'while' loop the counter is initialized outside of the 'while' loop. Inside the parentheses of the loop the condition is set to stop looping when the counter reaches a value of 5. Inside of the 'while' loop block the counter is set to increment by 1 value each time the loop iterates.

int i = 0;

while ( i < 5 ) {

i++

}

What are the importance of turbo c?

i came to know about that turbo c compiler is having 32 number of disadvantages........ i know about 10-12 disadvantages and i am sharing those wid u ....

1) Turbo c is a 16bit compiler ... means it can access about 16bits of data at a time...

2)Turbo c is based upon 8086 microprocessor... and it can run on x86family....

3) Turbo c is derived from MS-DOS whereas GCC compiler which runs on linux..is a very good one as compared to Turbo C compiler..,..

4)Also we cant do ODBC and Networking programming over the Turbo C comiler whereas we can do above programming in GCC compiler successfully by installing one ODBC library in it....

5)we cant do graphics programming over here, rather we can do graphics programming. in GCC compiler using Glad Interface...

6) Turbo C compiler can access only 1mb of RAM, which is a demerit...whereas GCC compiler can access 4gb OF MEMORY..

7)

7) Turbo C compiler is based upon MS DOS operating system.. which is a single process operating system..whereas GCC Compiler is based on 80386 processor(LINUX) and it is multiprocess operating system.....

How can use a function in c without declaration?

The syntax for a function declaration in C is:

return-type function-name(list-of-parameter-types);

The following example declares a function that takes an int type parameter and returns an int.

Example:int myFunction(int);

What are the disadvantages of an ordinary queue?

A situation will arise when few elements are inserted & then deleting first few items.

Now, if we try to insert an item we get the message "Queue overflow".

i.e., even if memory is available, we can not access these memory locations

Differentiate keywords and identifiers in C programming?

keywords:- every word in a c program is either a keyword or an identifier. All keywords are basically the sequences of characters that have one or fixed meanings. And these meanings in any circumtances , can't be changed. All c keywords must be written in lowercase (small) letters.

eg:- auto, break ,case, char, const, do, if ,double, else .....etc

identifiers:- identifiers r names given to program elements such as variables , arrays & functions. Basically identifers r the sequences of alphabets or digits.

Rules for forming identifier name

* the first character must be analphabet (uppercase or lowercase) or an underscore

* all succeeding characters must be letters or digits.

* no special characters or punctuatio symbols are allowed except the underscore"_".

* no two successive underscores are allowed.

* keywords shouln't be used as identifiers.

How do you use pow function in c?

Either you can use the pre defined function "pow" in the <math.h> header file OR you can make a user defined function to do the same operation.

1.Using the pre defined function in <math.h> :

The function is a of datatype double and accepts only values in double. So, prototype declaration is:

double pow(double x,double y);

Pass the values to the function and it'll return the value of xy. In the calling function it can be declared as:

double power=pow(x,y);

2.USER DEFINED FUNCTION:

double power(double x,int y);

int main()

{

double x,result;

int y;

cout<<"\nEnter the base: "<<;

cin>>x;

cout<<"\nEnter the exponential power: ";

cin>>y;

result=power(x,y);

cout<<"The result of x to the power y is: "<<result;

return 0;

}

double power(double x,int y)

{

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

{

x*=x;

}

return x;

}

What is the difference between local variable and global variable in Embedded C?

It's simple. A global variable has a scope through out out the C program. It can be accessed anywhere from any function or etc. A local variable on the other hand, is local to it's container only and can not be accessed outside of it's container. For example a function has variable sum then sum is only accessible within the function and not anywhere else.

What are the limitations of return statement in c language?

The only limitation is that the object returned from a function must be returned by value. We may return a pointer (by value) in order to return complex objects more efficiently, however the pointer must not refer to a non-static local object because non-static local objects fall from scope as soon as the function returns.

In C++ we do not have this problem because objects can be implemented with efficient move semantics, thus passing by value becomes an efficient means of returning complex objects from functions, including non-static local objects.

Which programming language should you use?

Depends on what you are trying to program! Games, web applications, mobile phone apps may use different languages. I'm not sure which ones use which as of 11-2009 but you need to determine that first!

A c program to generate a series of 1 3 6 10 15 21.?

As you can see, this series is the sum of the sequence: 1, 2, 3, 4, 5, 6.

That is to say:

1 + 2 = 3

3 + 3 = 4

6 + 4 = 10

10 + 5 = 15

15 + 6 = 21

To program this in C, you would want a simple incremental counter which would be added to the series sum on each iteration of the loop.

{

int c = 2;

int sum = 1;

// loop until you find all the numbers you want

while(1) {

// increase the running sum to find the next next number in the series

sum += c;

// increment our counter

++c;

}

}

What are the advantages of Turbo C plus plus?

The only reason to use Turbo C++ as opposed to, say, Visual C++ is because you chose to use a Borland IDE rather than a Microsoft IDE. If the question is why we use C++ rather than a specific IDE, then it is because we want high performance without all the the complexity of a low-level symbolic language such as assembler. If performance were not an issue, we would choose to use a more abstract, high-level language such as Java instead, which is ideally suited to rapid application development, but unsuitable for high-performance applications.

Write a program to accept a string from keyboard and count and display the numbers of vowels present in the string by using function?

You need to scan through the string and keep track of the vowelsoccurring. Here is a sample program:

#include

#include


int countVowels(char[] s){

int count = 0, i;

for( i=0; char[i] != '\0'; i++){

switch(char[i]){

case 'a':

case 'e':

case 'i':

case 'u':

case 'o': count++;break;

}

}

return count;

}


int main(){

char str[256];

printf("Enter the string:\t");

scanf("%s", str);

printf("The number of vowels in the string are :%d\n", countVowels(str));

return 0;

}

How can you print any statement without using semi column in c programming language?

I know this can be done or your teacher would not have given this question as homework.

The truth is I do not have a clue how to do this because in the real world it is not necessary to know or be able to do this. Ask your teacher or read your text book.

C programming?

The question is somewhat vague. Could you elaborate?

What are the political functions of a language?

When a Language is well developed then If any political party arises between that language people then the political group will be a linguistic group. The political group will support the customs followed the language speakers. thus they become supporters of the particular group people thus the gain popularity. Language influences the activities of the political group.. I mean the Literature plays a key role as the people follow the practices mentioned in their literature. If you arent satisfyied I'm sorry. Have a good day!!

What is the difference between system call and library function call?

On one level, there is no difference. They are both function calls. The only difference is in what they do.

System calls do something the user program cannot do; something having to do with system resources: memory, files, devices, network, terminals, processes etc.

However, system calls are usually implemented by library function calls because, at the root of the matter, a C or C++ program can only invoke function calls to call upon the operating system to do things.

How many data types are in c?

There are only 5 built-in types in C. They are char, int, float, double and void. All other types are modified types, user-defined types, or aliases (typedefs). If a modified type does not specify a type, int is assumed, thus a long is a long int while a short is a short int. Both char and int can be modified with the signed or unsigned modifiers. The float and double types are always signed but a double can be modified with long to create a long double. User-defined types include structs and unions. All types can be further modified with the suffix operator to create arrays of the given type. Furthermore, all types can be prefixed with the pointer operator to produce a pointer of the given type.

Can a C or CPP program compiled on Linux run on Windows and vice versa assuming that both the OSs are loaded in and can run on the same machine?

No. Windows and Linux have different APIs and ABIs for programs to access. You cannot run Linux binaries on Windows, and you can only run Windows binaries on Linux if you have Wine installed.

What is the difference of non void and void function?

If a method call is void, that means it will not return a data value to a program that calls it. Otherwise, the method is expected to return a data value of some sort.

For example, if I have a method called print() that is void, and the body of the method has a command to print a word to the screen, the method will run that command and end.

However, if I have a method called add(int x, int y) that takes two numbers and adds them together, the program calling this method wants an answer back. So this method is not void.