What are the wildcard characters in C?
The wildcard characters in C programming include the asterisk (*) and the question mark (?). An asterisk stands for any missing number of characters in a string while a question mark represents exactly one missing character.
Nintendo is in Japanese like NREIALKEN GFRTAO and Carue is in Espan'ol like YURKO WILF as high level of Nintendo and Carue of something.
C programming is called middle level language?
(i) it gives or behaves as High Level Language through Functions - gives a modular programming and breakup, increased efficiency for reusability
(ii)it gives access to the low level memory through Pointers. Moreover it does support the Low Level programming i.e, Assembly Language.
As its a combination of these two aspects, its neither a High Level nor a Low level language but a Middle Level Language.
Of note: C++ supports pointers and some basic assembly aspects. It is, however, high-level. C is 3rd generation, not due to pointers or functions, as most languages after the 1st generation include some implementation of these, but because it introduced the first (relatively speaking) aspects of object orientation (structs and enums). C++ carried on with this, leading to the "4th", which has become too varried to refer to as such. There is no such thing as a middle-level language. Machine code to BASIC to C to C++ and Java and such, C is definitively on the higher end of the programming specture.
What are the c-programs for file allocation techniques?
// Indexed Allocation
#include
#include
#include
struct node {
int file_name;
int data;
int is_free;
int size;
int directory;
int cnt;
struct node* link;
struct node* inner_link[30];
};
struct node* defaultFile() {
struct node* temp = (struct node*)malloc( sizeof(struct node) );
temp->link = NULL;
temp->is_free=0;
temp->data='a';
temp->file_name=99;
temp->directory = 1;
return temp;
}
struct node* insert(struct node *rt, int size, int fname) {
struct node* temp = rt;
struct node* first=NULL,*last=NULL,*tt=NULL;
int flag=0,act_size=0, inner_fname=100,cnt=0;
last=first;
act_size = size;
if ( size>temp->size ) {
printf("There is not enough space on the disk to write that file\n");
return rt;
}
while( temp->link ) {
temp = temp->link;
}
first = defaultFile();
while( act_size>0 ) {
tt = defaultFile();
if (act_size>50)
tt->size = 50;
else
tt->size = act_size;
tt->file_name = inner_fname;
first->inner_link[cnt] = tt;
tt->directory = 0;
tt->is_free = 0;
act_size -= 50;
inner_fname += 1;
cnt += 1;
}
temp->link = first;
first->is_free = 1;
first->cnt = cnt;
first->size = size;
first->file_name = fname;
act_size = rt->size;
rt->size = act_size-size;
return rt;
}
void printFiles(struct node* rt) {
struct node *temp = rt, *tt;
int first=0,cnt=0;
printf("format is (File name, size)\n");
printf("\t(%d,%d)\n",rt->file_name,rt->size);
while( temp ) {
if ( temp->is_free ) {
printf("\t(%d,%d)\n",temp->file_name,temp->size);
first = 0;
while( cntcnt ) {
tt = temp->inner_link[cnt];
printf("\t\t(%d,%d)\n",tt->file_name, tt->size);
cnt += 1;
}
printf("\n");
}
temp = temp->link;
}
}
struct node* combine(struct node *rt,int fname) {
struct node *temp=rt,*nt=NULL,*temp1=temp->link;
int size=0;
if ( rt->file_name==fname ){
printf("You cannot that file as thats just to show that that much amount of space is left in the disk\n");
return rt;
}
while( temp1 ) {
if (temp1->is_free==0 && temp1->file_name==fname ) {
size = temp1->size;
temp->link = temp1->link;
temp1 = temp->link;
}
else {
temp = temp1;
temp1 = temp1->link;
}
}
rt->size += size;
return rt;
}
struct node* deleteFiles(struct node* rt, int fname) {
struct node *temp = rt,*nt=NULL;
int flag=0;
while( temp && flag==0 ) {
if (temp->file_name==fname) {
temp->is_free=0;
flag=1;
}
temp = temp->link;
}
if( flag==0 ){
printf("There doesnt exist any file with that name\n");
}
return combine(rt,fname);
}
int main() {
int flag,no,size,data;
struct node *root;
root = defaultFile();
root->size=1000;
data=100;
flag=no=size=0;
while( flag==0 ) {
printf("Enter no's \n1.insert\n 2.Delete\n 3.Print files \n 4.Exit\n");
scanf("%d",&no);
printf(" no is %d\n",no);
switch(no) {
case 1:
printf("Enter file size\n");
scanf("%d",&size);
root = insert(root, size, data);
data = data+1;
break;
case 2:
printf("Enter file name to delete\n");
scanf("%d",&size);
root = deleteFiles(root, size);
break;
case 3:
printFiles(root);
break;
case 4:
flag=1;
printf("Quitting from loop\n");
break;
default:
printf("Enter a valud no \n");
break;
}
}
}
How can we read two strings using c program?
#include,stdio.h>
main()
{
char string1[20],string2[20]
printf("enter the first string");
scanf("%s",string1);// reading the string1
printf("enter the second string");
scanf("%s", string2);// reading the the string2
printf( "the first string is %s",string1);// printing the string1
printf("the second string is %s",string2);// printing the string2
}
the problem of using scanf is that it does not take space. so we can use gets for it.
ie instead of scanf("%s",string1); we can use gets(string1); .
How do you find missing numbers in a array with elements below its size?
Please rephrase your question. An array usually has a fixed size and I don't recall ever having to "go below its size". This implies that the missing elements are not within the range of the array.
in C: a semicolon in itself. Examples:
1. while (*to++ = *from++);
2. { goto END; ... END:; }
Where can someone find a list of C Compilers?
One can find a list of C Compilers, along with helpful information at several online sites. Some of these online sites with this information are "Cplus" and "Delorie".
Can a machine having 64MB run an executable which is 300MB using far pointers?
Yes, but you will incur a substantial penalty in virtual address page fault rates. Also, the standard page overcommit ratio in Windows is 4 to 1, so you would only be able to have a 256MB address space.
What is the declaration of overloaded pre-increment operator implemented as member function?
The pre-increment operator accepts no parameters and returns the same object (by reference) after incrementing.
The post-increment operator accepts an unused (dummy) integer parameter and returns a copy of the object (by value) that is made immediately prior to incrementing the object.
Note that it is good practice to always use the pre-increment operator even if a post-increment operator exists. The only time you should ever use a post-increment is when you actually store the return value. If you don't store the return value then you will end up making an unnecessary copy, which is highly inefficient. With primitive data types that are less than or equal in length to a pointer this isn't a major issue, but it's good practice nonetheless. If you do it for primitives then you're far more likely to remember to do it for class instances as well.
The following example emulates an integer type with pre-increment and post-increment operators implemented:
class Simple
{
public: // Construction:
Simple(int data = 0):m_data(data){}
Simple(const Simple& simple):m_data(simple.m_data){}
public:
// Assignment:
Simple& operator= (const Simple& simple) {
m_data = simple.m_data;
return( *this ); }
// pre-increment:
Simple& operator++ () { // no parameters!
++m_data; // increment this object
return( *this ); } // return a reference to this object
// post-increment:
Simple operator++(int) { // int parameter (not used)!
Simple copy( *this ); // call the copy constructor
++m_data; // increment this object
return( copy ); } // return the copy (by value)
private:
int m_data;
};
How do you implement a deque using an array in c language?
A deque (pronounced deck) is a double-ended queue where objects can be efficiently pushed to and popped from either end of the queue.
Arrays are not ideally suited to this task because arrays operate more efficiently when used like a stack, pushing and popping elements at the end of the array where the unused elements are. When we run out of unused elements we can reallocate the array creating more space at the end as required (typically doubling the allocation with each reallocation). For this we need to keep track of three pieces of information:
A queue differs from a stack in that all insertions occur at the first unused element, while extractions occur at the first used element, which is initially at the start of the array. After an extraction we end up with an unused element at the start of the array. Although we could shunt all used elements by one element to eliminate the gap, it is more efficient to just keep track of the front of the queue. Thus we need 4 pieces of information:
From this information it is trivial to calculate the length of the queue (size-space) and thus determine where the first unused element is using modulo arithmetic: ((start+(size-space))%size).
When we run out of space at the end of the array for an insertion, we simply use the unused elements at the beginning of the array. When we run out of space completely, we normalise the array so that the start of the queue is back at the beginning of the array before reallocating the array, thus placing all the new unused elements at the end of the array (after the last element in the queue). If we don't normalise the array, we will most likely end up with unused elements in the middle of the queue due to the circular nature of the array.
To implement a deque we use a similar technique except we can insert and extract from either end of the queue. The following program demonstrates how the major deque operations can be implemented upon an array of unsigned integers.
#include
#include
#include
#include
// a deque of unsigned integers
typedef struct arraydeque_t {
unsigned* arr; // pointer to a variable length array of type unsigned
unsigned sz; // overall length of array (in elements)
unsigned space; // unused elements
unsigned start; // index of the start of the queue
} arraydeque;
bool is_empty (arraydeque*);
unsigned size (arraydeque*);
unsigned back (arraydeque*);
unsigned front (arraydeque*);
int initialise (arraydeque*);
int push_back (arraydeque*, unsigned);
int push_front (arraydeque*, unsigned);
int expand (arraydeque*);
void pop_back (arraydeque*);
void pop_front (arraydeque*);
void clear (arraydeque*);
// calculates and returns the length of the queue
unsigned size (arraydeque* deq) {
return deq->sz-deq->space;
}
// returns true if the queue is empty
bool is_empty (arraydeque* deq) {
return deq->space==deq->sz;
}
// clear the deque
void clear (arraydeque* deq) {
if (deq->arr) free (deq->arr);
memset (deq, 0, sizeof (arraydeque));
}
// initialise the deque
int initialise (arraydeque* deq) {
const unsigned sz = 1; // start with 2 unused elements
memset (deq, 0, sizeof (arraydeque));
deq->arr = (unsigned*) malloc (sz * sizeof (unsigned));
if (!deq->arr) return -1; // out of memory
deq->sz = sz;
deq->space = sz;
return 0;
}
// increase the size of the deque (create space)
int expand (arraydeque* deq) {
unsigned space, t, i, *p;
if (deq->space) return 0; // no need to expand when we have space
// normalise the array (realign the start of the queue with the start of the array
while (deq->start) {
t = deq->arr[0]; // temporarily store first element value
for (i=1; i
deq->arr[i-1] = deq->arr[i];
deq->arr[deq->sz-1] = t; // put temporary value at end of array
--deq->start;
}
// reallocate the array to create space after the queue
space = (unsigned) (0.6 * deq->sz + 1); // optimum growth: 160%
p = (unsigned*) realloc (deq->arr, (deq->sz + space) * sizeof(unsigned));
if (!p) return -1; // out of memory
deq->arr = p;
deq->sz += space;
deq->space = space;
return 0;
}
// insert value at the back of the queue
int push_back (arraydeque* deq, unsigned val) {
if (expand (deq))
return -1; // out of memory
deq->arr[(deq->start+size (deq))%deq->sz] = val;
--deq->space;
return 0;
}
// insert value at the front of the queue
int push_front (arraydeque* deq, unsigned val) {
if (expand (deq))
return -1; // out of memory
if (!deq->start)
deq->start=deq->sz;
--deq->start;
deq->arr[deq->start] = val;
--deq->space;
return 0;
}
// extract the back value
void pop_back (arraydeque* deq) {
++deq->space;
}
// extract the front value
void pop_front (arraydeque* deq) {
++deq->start;
deq->start%=deq->sz;
++deq->space;
}
// return the back value
unsigned back (arraydeque* deq) {
return deq->arr[((deq->start + size(deq)-1)%deq->sz)];
}
// return the front value
unsigned front (arraydeque* deq) {
return deq->arr[deq->start];
}
// returns true or false at random (used by test program)
bool is_true (void) {
return rand() & 0x1;
}
// prints the content of the deque (used by test program)
void print_queue (arraydeque* deq) {
unsigned i, sz;
printf ("{");
sz = size (deq);
i = deq->start;
while (sz--) {
printf ("%u%s", deq->arr[i++], sz?", ":"");
if (i==deq->sz) i=0;
}
printf ("}\n");
}
// test program
int main (void) {
unsigned i, loop;
srand((unsigned) time(0)); // seed random generator
arraydeque deq;
initialise (&deq); // initialise the deque
for (loop=0; loop<100; ++loop) {
if (is_true ()) {
i = rand() % 10;
if (is_true ()) {
printf ("Pushing %d to the front:\t\t", i);
if (push_front (&deq, i))
break; // out of memory
}else{
printf ("Pushing %d to the back:\t\t", i);
if (push_back (&deq, i))
break; // out of memory
}
print_queue (&deq);
}
else if (is_true() && !is_empty (&deq)) {
if (is_true ()) {
printf ("Popping %u from the front:\t", front (&deq));
pop_front (&deq);
}else{
printf ("Popping %u from the back:\t", back (&deq));
pop_back (&deq);
}
print_queue (&deq);
}
}
while (!is_empty(&deq)) {
if (is_true ()) {
printf ("Popping %u from the front:\t", front (&deq));
pop_front (&deq);
}else{
printf ("Popping %u from the back:\t", back (&deq));
pop_back (&deq);
}
print_queue (&deq);
}
clear (&deq);
return 0;
}
C program to find address of variable?
// Use the & operator (Sometimes called the "address of" operator
int variable = 7;
printf("Address of variable = %d\n", &variable);
printf("Value of variable = %d\n", variable);
How do you programme 1 232 34543 232 1 in C?
int main (void)
{
puts ("1 232 34543 232 1");
return 0;
} int main (void)
{ puts ("1 232 34543 232 1"); return 0; }
WHERE IS THE BEST PLACE TO FIND GOLD IN n.c.?
There is no one best place to find gold in N.C. because there are several mining locations. Among them include Guilford, Orange, Montgomery and Randolph.
Why are Inheritance super classes fragile?
Superclasses are considered fragile because seemingly safe modifications to a super class, when inherited by the derived classes, may cause the derived classes to malfunction.
If you want to use prototype it has to be declared before main(). If you have a function of type double with one argument of type int (with name arg), and the function name is func, then we have:
#include
...
double func(int arg);
...
int main(...)
{
...
return 0;
}
...
double func(int arg)
{
...
}
This is false. The movement described is a disadvantageof bubble sort.
How is one dimensional and two dimensional arrays read and written?
You go through all the elements of an array with a loop - or, in the case of a 2-dimensional array, with two nested loops. If you have a 10-dimensional array, you would use 10 nested loops. In any case, one variable to keep track of the position for each dimension.
What data type does the main function return in c?
The main function must return the int data type. A program that terminates normally should return the value zero to indicate no error. Not all execution environments make use of the return value (Windows in particular), however a command script or batch file can examine the ERRORLEVEL if required.
What is a valid variable data type?
1. If its natural or integer numbers- Integer(Int) data type. 2. If it consists of decimal or fraction part- Double or float data type. 3. If it has a single letter or sign- Character(Char) data type. 4. If its got many words(alpha-numerical)- String data type. 5. If the result has to be "true" or "false"- Boolean data type.
How do you get principal varivation from iterative deepening search?
You will get principal variation from iterative deepening search using sequential moves within the framework. It is important to note that this may slow down the search due to space requirements.Ê