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 GPS DGPS and the frequently used algorithm used in programming DGPS?

DGPS is one of two widely used methods to augment the accuracy of the GPS.

Most GPS chips will follow the NMEA standard so that is usually the preferred way of parsing both GPS and DGPS data. Check out the related links for a link to the NMEA GPS standard.

Advantage of unity game engine?

Unity has so many tools that comes with it there is almost nothing you need besides unity except a image editing program like photoshop or for 3D, a 3D modeler. Also there is a really big community so there is somebody out there that could easily answer your question. With the big community comes tons of YouTube videos. I couldn't begin to count how many unity tutorials there are. Finally you can do ALOT without having to do a lot of programming. You can do things like ads physics to a game object without having to one line of code.

Example of motivation?

Effective extrinsic motivation encourages a behavior by providing an external reward such as gifts, money, praise, power, recognition, etc.

What is language ego?

Language ego refers to a person's sense of self that is tied to their language or linguistic abilities. It affects how individuals perceive their own worth and intelligence based on their proficiency in a particular language. Language ego can impact communication, language learning, and social interactions.

What is an example of a logic error?

A logic error (also known as a semantic error) is a flaw in the thought process behind a piece of code, in such that although the code itself is written correctly it does not serve the intended purpose for which it was written.

An example of this in basic English would be aiming to add 1 and 1 together to get 2, but accidentally using the minus symbol instead of the addition; the sum can still be done, but it will yield an incorrect result.

Transfer that to a simple bit of code then:

Dim a as Integer = 1

Dim b as Integer = 1

Dim c as Integer

c = a - b

MsgBox("Look! I added 1 and 1 together and got: " & c)

Obviously since the intent was to add two numbers together, there is a flaw in the logic of the code.

A logic error is notoriously difficult to debug from a program due to the fact the code itself is written perfectly correctly; this means the code will not crash and error detectors have no way of knowing what you intended the code to do if it worked correctly.

Logic errors are traditionally solved through the tedious method of tracking variables and going line by line through the code one step at a time, following it logically through each step until you find the exact point an incorrect value is generated; thus identifying the segment of faulty code.

What is the advantage of doubly linked list over singly linked list?

It's not that one is better than the other. They are used in different circumstances. A linear linked list is used like an array, with the added benefits of random insertion/removal of elements, etc. A circular linked list is often used as a buffer where one portion of the program produces data and another consumes it, such as in communications.

What is hetrogenious linked list?

A heterogeneous linked list is a linked list where each node can store different types of data. This is different from a homogeneous linked list where all nodes store the same type of data. Heterogeneous linked lists can be useful for scenarios where you need to store multiple types of data in a single list.

What is a circular singly linked lists?

A circular singly linked list is a memory structure in programming that supports walking around the list in a circle. Such a list is almost always written in the following form:

class ListNode {

public ListNode nextNode;

public Object nodeData;

public void addNode(Object newData);

public void removeNode();

}

Note that I've just generalized the data structure, as each language will have a specific syntax that has to be followed.

The data is organized such that if you follow nextNode indefinitely, you will eventually circle all the way back to the original node you started at. This is the "circular" part of this list. Going in a circle is done like this:

while(ListNode node = CurrentNode.nextNode) {

/* Do some processing here */

}

Depending on the actual use case, care must be taken to ensure that you are not truly going around infinitely.

The "singly linked" part is identified by the single pointer (or reference, if you will) to the next available node, called nextNode. A "doubly linked" structure would also contain a "previousNode" pointer/reference.

void addNode(Object Data) {

ListNode temp = new ListNode();

temp.nextNode = CurrentNode.nextNode;

temp.Data = Data;

CurrentNode.nextNode = temp;

}

Inserting a new node can be done by inserting after the current entry. Inserting in place of the current entry would be slightly more complex, because you'd have to move the data pointers in the current node to the new node, then place the new data into the current node.

void removeNode() {

CurrentNode.nextNode = CurrentNode.nextNode.nextNode;

}

This code removes the node after the current entry. Again, to remove the current node instead of the one following, you would move the data from nextNode into the current node, then delete nextNode.

In a modern programming language, the old node will be garbage collected after a period of time, thus reclaiming the memory used. In other languages, you would need to "free" or "delete" the ListNode that was contained in CurrentNode.nextNode.

How do you implement a doubly linked list by using singly linked list?

Add another pointer to the nodes for the previous node:

struct node {

struct node *next;

struct node *previous;

void *data;

};

typedef struct node node;

Then change the logic for insertion and removal to make sure you set the previous pointer as well as the next one.

What is heterogeneous linked list?

Heterogeneous Linked List is a linked list data-structure that contains or is capable of storing data for different datatypes.

void pointer is basically used in these types of linked list as we are not sure of which type of data needs to be stored

Give 10 difference between dda and bresenham algorithm?

  1. DDA algorithm involves floating-point operations, while Bresenham algorithm uses only integer operations.
  2. DDA algorithm calculates the exact position of each pixel, while Bresenham algorithm determines the closest pixel to the ideal line path.
  3. DDA algorithm can suffer from precision issues due to floating-point calculations, while Bresenham algorithm is more accurate and efficient.
  4. DDA algorithm is simpler to implement but slower than Bresenham algorithm.
  5. DDA algorithm is susceptible to rounding errors, while Bresenham algorithm is not.
  6. DDA algorithm can produce jagged lines due to rounding errors, while Bresenham algorithm generates smoother lines.
  7. DDA algorithm is suitable for both lines and circles, while Bresenham algorithm is primarily used for drawing lines.
  8. DDA algorithm can handle lines with any slope, while Bresenham algorithm is more efficient for lines with slopes close to 0 or 1.
  9. DDA algorithm involves multiplication and division operations, while Bresenham algorithm uses addition and subtraction operations.
  10. DDA algorithm is a general line drawing algorithm, while Bresenham algorithm is specialized for line drawing and rasterization.

What is the difference between doubly linked list and circular linked list?

A doubly linked list is a linked list in which each node knows where both of its neighbors are.

A circular linked list is a linked list in which the "tail" of the list is linked to the "root". (Note that both the tail and root of the list are undefined/arbitrary in a circular linked list)

Doubly linked lists are actually not necessarily related to circular linked list (aside from both being based on a linked list structure). In fact, you can have a circular doubly linked list, where each node knows where both of its neighbors are andwhere the list wraps around to connect to itself.

Write a C program to accept the elements of a 3 x 3 matrix and find its sum of the major diagonal elements The program should print the given matrix along with its sum of the major diagonal elements?

#include <stdio.h>

#include <conio.h>

void main() {

int d[3][3] = { 1, 2, 6, 3, 8, 5, 5, 6, 7 };

int k = 0, j = 0;

int sum1 = 0, sum2 = 0;

for (j = 0; j < 3; j++) {

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

printf(" %3d", d[j][k]);

printf("\n");

}

for (j = 0; j < 3; j++) {

sum1 = sum1 + d[j][j];

}

k = 3 - 1;

for (j = 0; j < 3; j++) {

if (k >= 0) {

sum2 = sum2 + d[j][k];

k--;

}

}

printf("Sum of First diagonal= %d\n", sum1);

printf("Sum of Second diagonal= %d", sum2);

getch();

How do you find whether linked list is circular or not?

To determine if a linked list is circular, you can use the Floyd's cycle detection algorithm. This algorithm involves using two pointers moving at different speeds through the list, and if there is a cycle, the two pointers will eventually meet at the same node. If they don't meet and one of the pointers reaches the end of the list, then the list is not circular.

Main deffrent between c and cpp?

The main difference between c and c++ is the concept of 'Object Oriented Programming' (OOPS).

Thus c does not have the benefits of oops like:

1. abstraction

2. encapsulation

3. inheritance

4. polymorphism etc.

Common operation of singly linked list?

Common operations on a singly linked list include insertion (at the beginning, end, or specific position), deletion (from the beginning, end, or specific position), traversal (visiting each node in the list), searching (finding a specific value), and updating (modifying the value of a node).

C program to find sum of all elements of a matrix?

/*

@Autor: MD moniruzzaman

http://www.youngprogrammer.com

*/

#include<stdio.h>

#define maxn 5

int matrix[maxn][maxn] = { {1,2,3,3,4},{2,3,4,1,2},{ 4,5,6,7,8},{3,4,5,6,9},{4,3,2,1,0}};

/*

Given matrix is:

1 2 3 3 4

2 3 4 1 2

4 5 6 7 9

3 4 5 6 9

4 3 2 1 0

*/

int main() {

int sum = 0, i, j;

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

for(j = 0; j<5; j++) {

sum+= matrix[i][j];

}

}

printf("%d\n",sum);

return 0;

}

Ladderized if or else conditional statement?

In a ladderized if-else conditional statement, multiple if-else blocks are used to check conditions in a hierarchical order. As soon as a condition is met, the corresponding block of code executes, and subsequent conditions are not checked. This approach helps streamline the logic flow and prevents unnecessary checks once a condition is satisfied.

What is a queses?

It seems like "queses" may be a misspelling or a typo. Did you mean "queso," which is the Spanish word for cheese? Queso is a popular ingredient in Mexican cuisine and is often used in dishes like nachos and quesadillas.

Find the sum of the digits of 33333333334 to the second power?

first you multiply 33333333334 by 33333333334

(if its kinda hard to count these, they both have ten 3's, and one 4)

and then you should get this:

1111111111155555555556

(for this one, there are eleven 1's, ten 5's, and one 6)

then you add all these digits together, and should get this:

67

***p.s. the reason why it's not 1156 is because, in the order of operations, you have to solve the exponents (to the second power) before you can start adding***

What is the difference between traversal and search?

Traversal simply means moving from one node to the next. Generally one searches by traversing the list, comparing each node's data with a given datum, either to return a pointer to a single matching node, or to return a list of matching nodes (copied from the list being searched), or simply to collect data about the matching nodes (such as a count of all the matching nodes).

What are conditional statements?

Conditional statements are used in programming to make decisions based on certain conditions. They allow the program to execute different code blocks depending on whether a condition is true or false. Common conditional statements include if, else, and else if.

Differences between finite and infinite loop?

A finite loop executes a specific number of times based on its condition, while an infinite loop runs indefinitely without cessation. Finite loops have a predetermined endpoint, while infinite loops continue without a defined stopping condition until manually interrupted. Improperly written infinite loops can lead to system crashes or unresponsive programs.

Whats the advantages of decimal search?

Advantages:

  • Its easy to work out
  • It establishes a value incredibly close to the root
  • Its easy to follow and understand

Disadvantages:

  • It is a very slow process
  • If the results are always towards the end of the intervals it will take a long time to find the sign change.

hope that's alright


Also, When there are two or more repeated roots of an equation, it does not find this root (as the sign is the same on both sides of the root) and another method has to be used.