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 many operators are there in C Language?

There are several operators in the C programming language, which are used to perform various operations on variables and values.

Here is a list of some of the most commonly used operators in C:

Arithmetic operators: +, -, *, /, % (addition, subtraction, multiplication, division, modulus)

Assignment operators: =, +=, -=, *=, /=, %=, &=, |=, ^=, =

Comparison operators: ==, !=, , = (equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to)

Logical operators: && (AND), || (OR), ! (NOT)

Bitwise operators: &, |, ^ (AND, OR, XOR)

Increment and decrement operators: ++ (increment), -- (decrement)

Conditional operator: ?: (ternary operator)

It's important to note that there may be some additional operators depending on the specific C compiler or implementation being used.

Explain how memory is represented in a linked list data structure?

Type your answer here...  Let lists be a linked. Then list will be maintained in memory unless otherwise specified or implied as follows. First of all list required two liner array we will call them here INFO and LINK such that INFO[K] and LINK[K] contain, respectively, the information part and the next pointer filed of a node of list.

 As noted above list also required a variable name such as start which will contain the location of the beginning of the lists and the next pointer sentinel denoted as null which indicates the end of the lists

 Since the subscripts of the array INFO and LINK will usually be positive, we will chose null otherwise started.

Which produces faster program execution a compiler or pure interpreter?

A compiled program would execute faster than an interpreter running the same code step by step.

Why return type is not considered while overloading a function?

YES only if: The return type in the child class is a sub-type of the return type of the parent class.

Ex:

public int getName() {} - Parent class method

public String getName() {} - Child class method

If we implement the above two methods in the class hierarchy we will get compilation errors. whereas if we try the below implementation it will work:

public Object getName() {} - Parent class method

public String getName() {} - Child class method

This is because String is a sub-type of Object and hence it works.

This is also called as Covariant Overriding.

Note: This feature is available only from Java 1.5. Earlier versions of Java expect overriding methods to have exactly the same return type as the super class method.

Write a program in'C' language for the implementation of a Stack?

c program for implement a stack using two queue First push the given elements in stack1... then pop those elements and push them in 2nd stack... now pop the elements from this stack... thus implemented queue

Difference Between Variable And constant?

A constant and variable are variations of data types.

int a;

is a variable and its value can be changed by the program as the program runs.

const int b;

is a constant with a fixed value and will have its value set and may not be changed by the program as as the program runs.

All data types may be declared as a constant.

Variable Value Can Be Changed By You In Programme.

What are the two types of comments in c programming language and how do they differ?

C uses two types of comment: single-line and multi-line. The multi-line comment originated in C while the single-line comment originated in C++. Both types are supported by both languages today.

A single-line comment begins with the double-slash token (//) and extends to the end of the line.

A multi-line comment begins with the slash-asterisk token (/*) and ends with the asterisk-slash token (*/).

Examples:

int x; // this is a single-line comment

/* this is multi-line comment, typically

used to introduce a function or class */

Note that since multi-line comments are fully-delimited, they may be used within the middle of a line of code. This is most useful when a function is forward-declared with a default value for one of its arguments and you wish to include that default value in the function definition (something which is not permitted under the one-definition rule):

void f (int = 0); // declaration

void f (int x /* = 0 */) { // definition

}

Such usage is really only of use to the function maintainer, as a reminder that the function has a default value.

We can also use this technique when a function has an argument that is reserved for future use, but is otherwise unused in the current version of the function:

void g (int); // declaration

void g (int /* unused */) { // definition

}

Again, such usage is only of use to the function maintainer.

Call by reference in c?

If you are calling by reference it means that compilator will not create a local copy of the variable which you are referencing to. It will get access to the memory where the variable saved. When you are doing any operations with a referenced variable you can change the value of the variable.

It is a technique whereby the called function receives values from its calling function, stores these values in its local arguments and returns a result. The called function does not have access to any local variables in the calling function. Anything passed into the function call is unchanged in the caller's scope when the function returns.

No, C uses call-by-value. Of course you may use pointers as parameters.

What are the ranges of basic datatype of C' programming languages?

Basic built-in data types in the C programming language are scalar types in variations of char, int and float:

char, unsigned char, signed char

int, signed int, unsigned int, short, signed and unsigned short, long, signed and unsigned long

float, double

Named enumerations are supported. These are weakly typed constant literals of type int. Bitfields are supported as range-limited signed or unsigned integers. Neither qualify as a type in their own right.

Some dialects also support additional types, such as wide character, extra large integers or floating point scalars.

The language also knows a related keyword void, which is used to express the fact that the related item has no known or no specific type. void in itself is not a type (it is rather the absence of a type).

The C programming language also supports three basic aggregates: structure, union and arrays.

Pointers can reference any of the scalar built-ins, enumerations, structures, unions, arrays, and the infamous void. Pointers are viewed as a data type by many.

Other members of the C family of languages also support class and interface types and strongly typed enumerations.

What is the disadvantage of array in c?

Disadvantages of C are:

1. There is no runtime checking.

2. There is no strict type checking (for ex:we can pass an integer value for the floating data type).

3. As the program extends it is very difficult to fix the bugs.

C is a middle level language so it can be used for interaction with the hardware easily, at the same time it can interact with the user...

It uses the POP (Procedure Oriented Programming) approach which is its major disadvantage..

Advantages include its interaction with hardware, easy to learn, code is secure

Compact and efficient. Many people find it rather very difficult to work with.

Another opinion:I do not think C has any disadvantages but others think differently. The correct answer that you need is the answer your teacher wants, ask your teacher or read your text book.

Another answer:

C has been made by real programmers, for real programmes. Just like UNIX. If you think that C (or unix) is not your cup of tea, then most likely you are right -- don't try to force.

How to write a program to print 1 2 3... series in C?

main(){

int temp,prev,i;

for(i=2,prev=1;prev<=256;i++){

printf("%d ",prev);

temp=i;

i=i*prev;

prev=temp;

}

}

How is the C programming language not object-oriented?

A "pure object oriented language" is one where every thing in it is treated on a consistent basis as on object, including elementary data types such as an integer. Since C++ treats elementary objects differently than classes, it does not meet the formal definition as a "pure ...".

How to use graphics in c plus plus?

At the beginning in the header file:

#include <graphics.h>

Why is it necessary to flame the loop between cultures?

because when we inoculate the culture with wire loop,some organism may be sticked to it which may be harmful or can cause trouble.so to destroy the remaining organisms wire loop is flamed again.

A source program is the program written in which language?

It is programming that is licensed in such a way that it provides the source code for everyone to view and suggest changes to, and is usually at no cost or a very lost cost to anyone that wants the program and its source code.

Difference between reference variable and instance variable?

An object is the actual storage space in memory in which some collection of data resides.

A reference variable is a variable which refers to the memory location of an object.

Look at the pseudocode below:

Object obj = new Object();

Here obj is the reference variable, and the data to which it refers is the object.

What is auto declaration in C?

Auto is one of the four storage classes in c. This is the default storage class. The auto storage class can be used only inside functions, i.e. only to declare local variables and not to declare global variables. All the local variables are by default auto variables.

Other storage classes are:

Register - variables declared may get stored in CPU registers instead of RAM

Static - default storage class for global variables

extern - defines global variables that is visible to all object modules

How you can add a user define function in c library?

user defined functions r d functions whch user declare before the main functn in c program...

for eg.

double min( doub;le x,double y);

int factorial( ,)

int square(int)

etc

What is the difference between uninitialized pointer and null pointer in c language?

A null pointer is a pointer that has been initialised with the NULL value (zero). An uninitialised pointer is one that has not be initialised to any value and will in fact store whatever value happened to reside in the pointer's own memory address at the point of instantiation. Uninitialised pointers are a clear sign of bad programming because the only safe way to determine if a pointer is valid or not is to compare its value with NULL. An uninitialised pointer will almost always be non-NULL, which means you run the risk of accessing memory that either does not belong to you, or is otherwise invalid. Most compilers include a debug switch to warn you when you attempt to access any uninitialised variable, which naturally includes pointer variables. This switch must be on at all times.


Whenever you instantiate a pointer, always initialise it straight away, either by nullifying it, or by storing a valid memory address in it. When you are finished with the pointer, it's good practice to nullify it immediately, even if the pointer would subsequently fall from scope. If the pointer is to be immediately re-assigned, there is no need to nullify it (but it's good practice nonetheless). If you follow this practice at all times, you can be assured that any non-NULL pointer will always be pointing at something valid (and if it isn't, then you have some serious problems elsewhere in your code).


As a rule of thumb, if you can use a reference rather than a pointer, use a reference. They are much easier to work with. Pointers should only be used if there's any possibility (however remote) that a reference could be NULL, because a NULL reference will completely invalidate your program (pointers can be NULL, but references can never be NULL). This is why functions such as malloc() and calloc(), and the C++ new operator all return pointers rather than references. You can only return a reference when an allocation is guaranteed to succeed, and a dynamic memory allocation simply cannot make that guarantee.


Need of structured programming?

That basically refers to a programming language that has support for conditional statements (if), code repetition (while, for, ...), and subroutine or function calls. Most modern language have that. The term is also sometimes used for languages that do NOT work with OOP. Actually OOP includes the structured programming concepts mentioned above, but it includes a few other things, too.

What is the height of a binary tree with n nodes in the worst case?

For the height `h' of a binary tree, for which no further attributes are given than the number `n' of nodes, holds:

ceil( ld n) <= h <= n

Where `ld' is the binary logarithm and `ceil' is rounding up to the next integer.

What are the duties of switchboard operator?

the purpose of a switch board is a connection for

What is the code for a C program to find the largest and smallest number?

Fist of all, let's assume that by "list" you mean "array." Otherwise we would need your list implementation in order to be able to iterate through the elements.

int[] nums; // assume these are the numbers you want to search through

int nums_length; // also assume that we know how many numbers are in nums

int min; // smallest number in nums

int max; // largest number in nums

// special case for an empty list of numbers: set min = max = 0

if(nums_length == 0) {

min = 0;

max = 0;

}else {

// start min and max off as equal to the first number

min = nums[0];

max = nums[0];

// iterate through nums

int i;

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

// update max, if necessary

if( nums[i] > max ) {

max = nums[i];

}

// update min, if necessary

if(nums[i] < min) {

min = nums[i];

}

}

}

// min and max are now properly set (or both equal to 0 if nums is empty)

What is the if-then-else structure?

This is one of the most simple flow control mechanisms in programming. It follows very closely to the spoken-language version.

IF something is true

THEN do something

ELSE do something else

if x == 1

print "x is one!"

else

print "x is not one!"