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 the difference between a string and an array?

Nothing whatsoever. A string is simply an array of type char.

In some programming languages, such as C, a string is an array of char (or short), terminated with a null \0.

An array is just a fixed size of collection, a container to hold things/objects. If all the elements in the container are characters (of char), then we may call it a string, sometimes a byte array (because each character can be represented as a byte).

An array of 7 different days, it maybe a WEEK, or just the birthdays of 7 dwarfs. Then they are nothing to do with strings.

A data item (or variable) is described as a "string" type when it contains some number of characters. Those characters can usually be anything in the system's accepted list of codes. Most systems use ASCII, so a string can include the letters a-z, A-Z, numbers 0-9, and special characters like ~!@#$%^&*()_+-=[]\{}|:";'<>?,/. A string is treated as a single object, although most programming languages have methods to break strings apart (called sub-stringing). In the Perl language, strings are named $something.

An array is a collection of individual data items, sort of like a list. Each element in an array can be referred to in a program by its position in the list. In the Perl language, an array would be named @SOMETHING. The first element in the array would be named $SOMETHING[0], the second $SOMETHING[1], and so on. Each element can be a string, or some other data type.

Other data types would be integers (positive or negative whole numbers), floating point (decimal numbers like 3.14159 or 2398.41; it can be more complicated than this, but that's another story), and a few more exotic types.

In the C programming language a string is actually the same as an array of characters. The last character in a C string is a zero byte which indicates the end of the string.

C program to display a number entered by user as it is without skipping the zeros preceding the number?

// Define and initialize input buffer

char inputBuffer[256];

memset(inputBuffer, '\0', 256);

// Get input

scanf("%s", inputBuffer);

// Display exactly what the user typed in

printf("%s\n", inputBuffer);

What is m way search tree?

m-way trees are mainly useful when data exist in large amount

What is sparce array?

sparse array is one which has contents lower than its maximum size, that is the array has free or empty locations....

Why are Dubhe and Merak called pointers?

because they have three star in the solar

by melinda Myers

Matrix addition of a 33 matrix?

Fix 33 table changes : macierz1[][],macierz2[][],... and its size (write size to brackets)

Fix a matrix to result : wynik[][], and int i,j.

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

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

wynik[i][j]=macierz1[i][j]+...+macierz33[i][j];

Or instead of 33 changes: macierz[33][size][size]

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

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

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

wynik[i][j]=wynik[k][i][j]+macierz[k][i][j];

(dont forget about initializing wynik as 0 in 2nd case)

What is a singly liked list?

I believe it's simply a list of objects, with each object pointing to the next object. There is a value which keeps track of the list location (the head). Also the last object points to null.

head ----- data|pointer -----> data|pointer -----> data|pointer -----> data|NULL

This is a very basic form of such a list, and it's pretty inefficient, especially when it comes to adding values to the end of the list. A way to improve that would be to add a 'tail' variable so the last value can be easily found.

What is a backtrace?

A backtrace is another term for a stack trace, in computing, a hierarchical trace of the function calls made by a program, as used in debugging.

Is there any pointer called ds cs es ss pointer in C programming?

yes, ds cs es ss are pointers available in c which is used to refer memory segments

What is binery code?

Any code in which character values are not restricted to printable characters.

Two Binary Trees are similar if they are both empty or if they are both non-empty and left and right sub trees are similar Write an algorithm to determine if two Binary Trees are similar?

/*

Given two trees, return true if they are

structurally identical.

*/

int sameTree(struct node* a, struct node* b) {

// 1. both empty -> true

if (a==NULL && b==NULL) return(true);

// 2. both non-empty -> compare them

else if (a!=NULL && b!=NULL) {

return(sameTree(a->left, b->left) &&

sameTree(a->right, b->right)

);

}

// 3. one empty, one not -> false

else return(false);

}

What is a prejudicial statement?

Evidence that is admissible if its is inflammatory and will have the effect of biasing jurors.

Write a c program to find number of days in a month using enumerated data types?

#define leap year

void main()

{

enumeratedmonth{jan=1,

feb,

mar,

april,

may,

june,

july,

aug,

sept,

oct,

nov,

dec}

enumeratesd month month;

int day,days,a month

clrscr()

printf("enter no.of month");

scanf("%d",& a month);

switch(a month)

{

case jan:

case mar:

case may:

case aug:

case oct:

case dec:

printf(" no. of day=31"0;

days=31;

break;

case april:

case june:

case sept:

case nov:

days=30;

break;

default;

printf("wrong no.");

day=0;

}

if (day!=0)

printf("no. of days=%d/n",days);

if (a month==feb)

printf("29 if its a leap year");

getch();

}

How many oops concept in c?

OOP Features

OOP ideas are supported by default in programming languages like C++ and Java. I'll describe how object-oriented programming, which lacks built-in support in C, can be somewhat adapted to this course.

Class & Objects

First, we create a Human class with characteristics such as his name, gender, and color.

After that, he can build many individuals with varied characters in the earth (things), but all of them can differ in terms of their properties, such as name, gender, and hair color.

God gave me the name Gopi, and I am an instance/object of the class Human. And you are a distinct type of instance/object.

Inheritance

Inheritance occurs when one class incorporates a property from another class.

Inheritance is the process of reusing objects.

Now, God desires that the Human class has properties such as hands, legs, eyes, and so on, as well as functions such as walking, talking, eating, and seeing. However, he is also a made Animal on Earth with the same traits.

Abstraction

"To express the core feature without representing the background details" is the definition of abstraction.

Abstraction allows you to concentrate on what the object does rather than how it does it.

Abstractions supplying pertinent information give you a generic view of your classes or objects.

Abstraction is concealing an object's working style while understandably displaying its information.

Encapsulation

It combines a data member and a method into a single unit (or class).

Encapsulation is the process of encapsulating something in a capsule. That is, confining an object's relevant activities and data within that object.

Encapsulation is similar to a bag in which you can keep your pen, book, and so on. This signifies that the property of encapsulating members and functions is present.

Encapsulation is concealing an object's internal characteristics or how it performs something.

Encapsulation keeps customers from viewing the interior view, where the abstraction's behavior is implemented.

Encapsulation is a technique for protecting an object's information from another object.

Polymorphism

Polymorphism is defined as "one name, multiple forms."

One function behaves in several ways.

Polymorphism is defined as "several forms of a single item."

What is subscript in bluej array?

In BlueJ, as in many programming environments, a subscript refers to the index used to access elements within an array. Arrays in BlueJ are zero-indexed, meaning that the first element is accessed with a subscript of 0, the second with a subscript of 1, and so on. For example, in an array called myArray, myArray[0] refers to the first element, while myArray[2] would access the third element. Using the correct subscript is essential for retrieving or modifying the desired elements in the array.

How do you right align in c?

for example:

for (i=1; i%3d. '%20s'\n', i, argv[i]);

Difference between declaring a variable and definition a variable?

Declaration is a promise: 'I will define (or has defined) this variable/function somewhere else'.

When does segmentation fault occur for a prog?

You either reference memory that is non existent, or you attempt to modify memory that is read only. This is usually a result of failure to properly initialize or use pointers or arrays.