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.
Pre indexing post indexing difference between?
what are the differents between preindexing and post indexing?
// 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);
m-way trees are mainly useful when data exist in large amount
sparse array is one which has contents lower than its maximum size, that is the array has free or empty locations....
Which function is supported by an application program?
which function is support by an application program
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)
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.
C plus plus program to find all even numbers between 100 and 150 using for loop?
#include
int main(){
int i;
for(i=2;i<=100;i=i+2){
printf("%d\n",i);
}
}
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
Any code in which character values are not restricted to printable characters.
/*
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();
}
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.
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.