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.

500 Questions

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

User Avatar

Asked by Wiki User

To implement a doubly linked list using a singly linked list, you can create two nodes in each element of the singly linked list - one for the next element and another for the previous element. This way, each node will have access to both its previous and next nodes, effectively creating a doubly linked list structure using a singly linked list implementation.

What is heterogeneous linked list?

User Avatar

Asked by Wiki User

A heterogeneous linked list is a data structure where each node can store data of different types. This allows for a flexible way to organize and manipulate data that may vary in structure or content. Each node contains a pointer to the next node in the list, enabling traversal and manipulation of the data.

Give 10 difference between dda and bresenham algorithm?

User Avatar

Asked by Wiki User

  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?

User Avatar

Asked by Wiki User

A doubly linked list allows traversal in both directions (forward and backward) by having each node point to both its next and previous nodes. A circular linked list is a type of linked list where the last node points back to the first node, forming a circular structure. This allows continuous traversal through the elements without a definitive end.

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?

User Avatar

Asked by Wiki User

#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?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

C is a procedural programming language, while C++ is a multi-paradigm programming language that supports both procedural and object-oriented programming. C++ has additional features such as classes, inheritance, and polymorphism that allow for more flexible and modular code design compared to C.

Common operation of singly linked list?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

To find the sum of all elements in a matrix in C, you can use nested loops to iterate through each element and accumulate the sum. Here is a basic example:

#include <stdio.h>

#define ROWS 3
#define COLS 3

int main() {
    int matrix[ROWS][COLS] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    int sum = 0;

    for(int i = 0; i < ROWS; i++) {
        for(int j = 0; j < COLS; j++) {
            sum += matrix[i][j];
        }
    }

    printf("Sum of all elements in the matrix: %d\n", sum);

    return 0;
}

Ladderized if or else conditional statement?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

Traversal is the process of visiting and processing each node of a data structure in a systematic way, often in a specific order, without the aim of finding a particular node. Search, on the other hand, is the process of looking for a specific node or element within a data structure based on certain criteria, such as value or key. Traversal is more concerned with exploring the structure as a whole, while search focuses on finding a specific element within the structure.

What are conditional statements?

User Avatar

Asked by Wiki User

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?

User Avatar

Asked by Wiki User

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.

Which is dummy operator in c?

User Avatar

Asked by Prasadh

In C, the sizeof operator can be considered a dummy operator because it does not perform any operations on the data but simply returns the size in bytes of a variable or a data type.

Whats the advantages of decimal search?

User Avatar

Asked by Wiki User

Decimal search is advantageous because it allows for greater precision in finding the desired value within a range, especially when the values being searched are continuous or have a narrow range of potential solutions. It can help to pinpoint the exact value without needing to iterate through a large set of values, saving computational resources and time.

What poet hated capital letters?

User Avatar

Asked by Wiki User

The poet who famously disliked using capital letters in his work is e.e. cummings. He believed that not using capital letters emphasized the equality of words and gave his poetry a more modern and unique look.

What are the limitations of getchar and scanf functions for strings?

User Avatar

Asked by Wiki User

cause getchar only read a character and scanf read only word before first space but not other words and letters.

What value is stored in uninitialized variables?

User Avatar

Asked by Wiki User

Some languages assign a default value as 0 to uninitialized variables. In many languages, however, uninitialized variables hold unpredictable values.

What is the main function of a video production company?

User Avatar

Asked by Wiki User

The main function of a video production company is to create videos for specific events or for companies. These companies are useful because they create high quality videos that help to add significance to the event or company.

66 c of b?

User Avatar

Asked by Wiki User

66 c of b typically refers to 66 cups of butter. That amount of butter is equivalent to approximately 16.5 pounds or 7.5 kilograms. It is a considerable quantity and would be used for large-scale baking or cooking purposes.

What is Latinate syntax?

User Avatar

Asked by Wiki User

Latinate syntax refers to the sentence structure and word order that is characteristic of the Latin language. It typically involves a more complex and flexible word order than English, with elements such as adjectives, verbs, and nouns often appearing in a different order than in English sentences. This style of syntax is often used in formal writing or rhetoric to convey a sense of sophistication or formality.

Write a program in c which will read a string rewrite it in alphabetical order?

User Avatar

Asked by Wiki User

Here is a simple C program that reads a string from the user, then sorts the characters of the string in alphabetical order:

#include <stdio.h>
#include <string.h>

int main() {
    char str[100];
    printf("Enter a string: ");
    fgets(str, sizeof(str), stdin);
    
    int len = strlen(str);
    for (int i = 0; i < len; i++) {
        for (int j = i+1; j < len; j++) {
            if (str[i] > str[j]) {
                char temp = str[i];
                str[i] = str[j];
                str[j] = temp;
            }
        }
    }
    
    printf("The string in alphabetical order is: %s\n", str);
    
    return 0;
}

C?

User Avatar

Asked by Wiki User

Help mr please