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 parameter passing by value and by reference to a function?

Pass by value means the value of the actual argument is assigned to the formal argument of the function. This is how all functions work in all languages, but in some languages, such as Java, the implementation details may be hidden from us so it may not be obvious pass by value is occurring. When we say pass by reference what we really mean is that the value being passed is a memory address rather than an ordinary value. That is; the memory address is being passed by value. Memory addresses can only be stored in pointers, so for a function to accept an address its formal argument must be pointer of the same type. In languages that do not support pointers, such as Java, the pointers are still there we just don't have access to them.

In C++ we also have a native reference type. A reference is nothing more than an alias, an alternative name for an object of the same type. Unlike a pointer, a reference cannot change which object it refers to; it always refers to the same object it was assigned when it came into scope. Moreover, a reference can never be null. As a result, references are much easier to work with than pointers because we know that an object must exist if we have a reference. With pointers, we must test the pointer is non-null before we can determine if it refers to an actual object. In addition, a pointer has storage and identity whereas a reference does not. If we attempt to take the address of a reference, we take the address of the object being referred to. If we take the address of a pointer we get the pointer's own address (as opposed to the address stored at that address).

Although C++ supports a native reference type, behind the scenes the compiler uses pointers to implement them. So references are really just passed by value the same way pointers are passed by value. Regardless, if a function accepts either a pointer or a reference, it is said to be using the pass by reference semantic, otherwise it is using the (default) pass by value semantic.

What is the advantage of auto indexing?

If you are referring to the use of the auto-increment/decrement operator, it is expressed more simply, and in some hardware architectures it is a hard-wired machine instruction, resulting in a faster program.

Why to use String in c?

C doesn't have String data-type, so don't use it.

What is a relational operators in c?

Relational operators are those operators which shows relation between two operands. e.g. ==, <=,>=,<,>

Program on matrix multiplication?

#include<stdio.h>

void main()

{

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

clrscr();

printf("Enter elements of A:");

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

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

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

printf("Enter elements of B:");

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

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

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

printf("A:");

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

{

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

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

printf("");

//To change line.

}

printf("B:");

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

{

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

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

printf("");

}

k=0;

while(k<=2)

{

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

{

int sum=0;

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

sum=sum+a[i][j]*b[j][k];

c[i][k]=sum;

}

k++;

}

printf("Result: ");

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

{

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

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

printf("");

}

getch();

}

IN a circular doubly linked list with 10 nodes what is the minimum number of links that might have to be changed if we want to delete a node other than the head node?

Two, but there is no "might" about it. For any node (including the head) we must update exactly two links:

node.next.prev = node.prev

node.prev.next = node.next

If the node is also the head then we also update the head node pointer:

head = node.next

Aside from deleting the head node, the only special case we need to deal with is when the node being deleted is the only node in the list because this will refer to itself (thus head = node.next would result in head pointing to a node we're about to delete). However, we can avoid this special case by using a sentinel node to represent the head of the list. In this way, every list, including an empty list, always has at least one node; the sentinel.

Note that with a circular doubly linked list there no need to keep track of the tail node given that the head node's previous node already refers to the tail. However, with a singly-linked circular list we only need to keep track of the tail node since the next node after the tail is always the head node.

What is an array diagram?

An array diagram is a visual representation of data organized in a grid format, typically used to illustrate the structure of arrays in programming or mathematics. It consists of rows and columns where each cell represents an element of the array, allowing for easy visualization of the relationships and organization of data. Array diagrams are commonly used in educational settings to teach concepts related to data storage, indexing, and manipulation.

What can a pascal triangle be used?

pascal was designed as a simplier version for educational purpose, it was also designed to be a teaching tool for students of programming classes.

How can you call a function given its name as a string?

we have to construct a table of two field structures,where the first field is the funtion name as a string and the second field is just the function name.then search the table to get a string match in the first field and use the second field to call the function.

C program to add the two numbers?

hi,this is jst a simple program to add numbers.i think u wil b satisfied wit ths

#include<stdio.h> //input output header file

#include<conio.h>

main()

{

int a,b,c;

clrscr();

printf("enter any number");

scanf("%d",&a);

printf("enter any number");

scanf("%d",&b);

c=a+b;

printf("%d",c);

getch();

}

When a object is passed to a function as argument why it is not generating an error if the parameterized constructor is defined and not the default constructor?

default constructor is used only when the programmer does not use a constructor to initialize objects. Once the programmer defines a constructor then the default constructor is no longer used

Who would you cast for the Secret Circle by L J Smith?

I would cast Megan Fox as Faye, Christian Serratos as Laurel, Taylor Lautner as Nick (or Steven Straight) and the rest I'm unsure of. Can't wait until the tv show comes out! I heard it was coming in March!!

How do you attach parity bit in c language?

for example:

unsigned char attach (unsigned char byte, unsigned char bit)

{

unsigned char mybyte;

mybyte = byte&0x7f;

if (bit) mybyte |= 0x80;

return mybyte;

}

What is semantic and syntactic?

Syntax refers to the set of rules that govern what sequences of symbols are valid programs or not. Semantics refers to what the various syntactic constructs actually mean, what they do, and so on.

How do you Write a C program for matrix?

/* multiplication of a 3*3 matrix*/

#include<stdio.h>

main()

{

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

int i,j,k;

printf("enter the elements in A matrix:\n");

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

{

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

{

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

}

}

printf("enter b matrix:\n");

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

{

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

{

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

}

}

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

{

printf("\n");

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

{

c[i][j]=0;

for(k=0;k<=2;k++)

{

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

}

}

}

printf("multiplication matrix is:\n");

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

{

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

{

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

}

printf("\n");

}

}