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 are the limitation of object oriented programming language?

  • Performance (since the generated code is much more than when working procedural)
  • Memory (more memory is needed to store code and data)

What are the functions of a utility program?

functions of utility program is to perform specific tasks related to the management of computer functions,resources or files as password protection,memory management,virus protection and file compression
This utility reads all V3 MMS output files, print out the header, partial sub-header and a value from all fields in the dataset.

What is the difference between mirco and macro?

macro-The climate of a large geographic area.

micro- is a local atmospheric zone where the climate differs from the surrounding area

How does loop work?

In programming, a loop works by conditionally jumping to the start of the loop and repeating the instructions. If the condition evaluates false, execution continues to the next instruction, thus breaking out of the loop. We can also break out of a loop from within the body of the loop itself using another conditional jump which jumps out of the loop. If we jump backwards out of a loop we effectively create an intertwined loop, known as spaghetti code which is difficult to read and maintain. Structured loops help make it easier to digest the logic. In C, a jump is achieved using a goto and a label. However, structured loops using for, while and do-while statements make loops much easier to read and maintain.

Can you specify variable field width in scanf format string?

Answer

You can't specify a variable field with a fixed format string, but you can get around this by making the format string variable:

int width; char format[20]; /* or whatever size is appropriate */ int value; ... sprintf(format, "%%%dd", width); /* generates a string like "%5d" */ scanf(format, &value);

The only drawback to this method, other than requiring two statements, is that the compiler can't do a sanity check on the arguments to scanf like it can when the format is a string constant.

Answer

If you want to specify a variable width in a printf format string (as opposed to scanf), you can do the following:

printf("%*d", width, num);

That will use the value of "width" as the width for formatting the value of "num" as a decimal integer.

What is a general loader scheme?

Loading schemes: 1.Absolute loader. 2.Relocating loader. 3.Direct linking loader. 4.Dynamic Loading. 5.Dynamic linking.

(1 )Absolute loader: The task of an absolute loader is virtually trivial.The loader simply accepts machine language code and places it into main memory specified by the assembler.

(2) Relocating loader: The task of relocating loader is to avoid reassembling of of all subroutines when a subroutine is changed and to perform tasks of allocation and linking for programmer.

(3) Dynamic loading: In order to overlay structure to work it is necessary for the module loader to load the various procedures as they are needed.There are many binders capable of processing and allocating overlay structure.the portion of the laoder that actually intercepts calls and loads necessary procedure is called overlay supervisor of simplly flipper.this overall scheme is called dynamic loading or load on call.

(4) Dynamic linking: This is mechanism by which loading and linking of external references are postponed until execution time.This was made to sort out disadvantage of previous loading schemes like subroutine is referenced and never executed

What is function overloading?

FUNCTION OVERLOADING:

- when we define two functions with same name,in same class(may be) distinguished by their signatures

- resolved at compile time

- same method bt different parameters in each of them

FUNCTION OVERRIDING:

- when we redifine a function which is already defined in parent class

- resolved at run time

- changing the existing method

What is similarity between a union and enumeration?

Nothing, only the syntax (very little).

Eg.:

struct {

int foo;

double bar;

} strtest;

enum {

monday=0,

tuesday=1, ...

} enumtest;

What is primitive style?

The definition of primitive characters is characters that are defining members of a clade that people believe rose early in the evolution of the group. They can be the characters of a large group who share being early members.

Why is using arrays with loops improve program efficiency?

Arrays provide the most compact method of representing one or more element of the same type in computer memory (whether in working memory or on disk). There is absolutely no memory overhead with arrays, other than when the array is allocated on the heap in which case you need to maintain at least one reference or pointer to the allocated memory. The structure of the array is built-in to the array itself, such that one element immediately follows another, and each element is exactly the same length (in bytes). This makes it possible to access any element in the array in constant time using simple pointer arithmetic. That is, knowing the start address of the array allows you to reference any element in the array using a memory offset or suffix operator. The first element is always found at offset zero (the start of the array) while the next is at offset 1. Thus for an n-element array, the final element will be at offset n-1. By offset, we really mean offset * sizeof (type), where type is the type of each element in the array. However, when working with arrays, the language knows the size of each type therefore we just use the offset as a zero-based index, where element 5 will be found at index 4, which is 4 * sizeof (type) bytes from the start of the array.

Given that arrays allow constant-time random access, loops make it extremely easy to traverse arrays from any element to any other element, both forwards and backwards. The loop control variable simply acts as the index to the element we wish to process on each iteration of the loop. We can also choose to skip elements if we're only interested in every other element, or every third element, simply by incrementing the control variable accordingly.

Looping through array indices is only efficient when you actually intend to traverse the array, such as when printing the entire array. When searching arrays for a specific value, loop traversal is the least efficient method. If we plan to search an array many times for many different values, it pays to sort the array first. We can then use the binary search technique, starting from the middle element. If that's not our element, the fact the array is sorted means we can eliminate one half of the array, depending on how the middle value compares to the value we are searching for. We then repeat the process with the remaining half, reducing the remaining elements by half each time until we either find our value, or the remaining half has no elements (in which case the value does not exist).

How do you pronounce queue?

There are many ways to pronounce it. The most common are pronounced like kwark and kwork

Who developed language C?

Dennis M. Ritchie developed the C language from 1969 through 1973 while working at Bell Labs. Although Brian Kernighan is often attributed as co-developer, he was actually co-author of 'The C Programming Language' book which came out in 1978 and served as the informal specification for what became known as "K&R C". Ritchie's original version is now referred to as "Classic C". K&R C was later replaced by ANSI C and is covered by Kernighan and Ritchie's second edition of the same book.

How do you learn the c plus plus language?

The same way you understand any computer language -- by learning the language. However, the learning curve is steep so it helps if you learn a much simpler language first, such as BASIC, so that you are familiar with basic concepts such as variables, arrays, loops and so on.

Where you can include a header file in the program?

You can include a file with the #include directive at any place you want to. You just have to consider that the compiler will see the total source file as if you had copied the contents of each include file at the point where you included it, and it will parse and process the total source file accordingly.

That said, header files, a subset of included files, are generally #include'd at the top of the source file. Again, it all depends on what is in the include file.

Find the smallest number and its position using array with c coding?

You simply walk through the array and whenever you find a smaller element you remember its value and location.

E.g. If you have an array of integers called pArray that contains 100 elements, here's what the code might look like:

int cPos 0, int nMin pArray[0]; // Provisionally assume the first element is smallest.

for ( int n 1; n < 100; ++n )

{

if ( pArray[n] < nMin )

{

// We've found a new smaller element, record its position and value.

nMin pArray[n];

cPos n;

}

}

Program to implement push operation in stack using c language?

#include

#include

void push(int st[],int data,int &top);

void disp(int st[],int &top);

int pop(int st[],int &top);

int flg=0;

int top=-1,tos=-1;

int st[50];

void push(int st[],int data,int &top)

{

if(top==50-1)

flg=0;

else

{

flg=1;

top++;

st[top]=data;

}

}

int pop(int st[],int &top)

{

int pe;

if(top==-1)

{

pe=0;

flg=0;

}

else

{

flg=1;

pe=st[top];

top--;

}

return(pe);

}

void disp(int st[],int &top)

{

int i;

if(top==-1)

{

printf("\nStack is Empty");

}

else

{

for(i=top;i>=0;i--)

printf("\t%d",st[i]);

}

}

void main()

{

int dt,opt;

int q=0;

clrscr();

printf("This Program Is Used to Perform PUSH & POP operations On Stack");

printf("\n\n\tMain Menu.........");

printf("\n\n1.Push");

printf("\n\n2.Pop");

printf("\n\n3.Exit");

do

{

printf("\n\n\tEnter Your Choice 1-3:");

scanf("%d",&opt);

switch(opt)

{

case 1:

printf("\nEnter the Element to be Push:");

scanf("%d",&dt);

push(st,dt,tos);

if(flg==1)

{

printf("\nAfter Inserting the Element, Stack is:\n\n");

disp(st,tos);

if(tos==50-1)

printf("\nStack is Now Full");

}

else

printf("\nStack Overflow Insertion Not Possible");

break;

case 2:

dt=pop(st,tos);

if(flg==1)

{

printf("\n\tData Deleted From the Stack is:%d\n",dt);

printf("\n\tAfter Deleting the Element from the stack is:\n\n");

disp(st,tos);

}

else

printf("\nStack Empty,Deletio Not Possible:");

break;

case 3:

q=1;

break;

default:printf("\nWrong Choice Enter 1-3 Only");

}

}while(q!=1);

}

OUTPUT

Main Menu.........

1.push

2.pop

3.exit

Enter your choice 1-3:1

Enter the element to be push:4

After inserting the elements,stack is:

4

Enter your choice 1-3:1

Enter the element to be push:7

After inserting the elements,stack is:

7 4

Enter your choice 1-3:1

Enter the element to be push:4

What is the algorithm for reverse a given number recursively?

//Function that reverses a given number

int reverse(int num)

{

static int sum,base =1;

sum=0;

if(num>0)

{

reverse(num/10);

sum += (num%10)*base;

base*=10;

}

return sum;

}

How do you write program c of table 5?

#include
#include
void main()
{ int a,i;
printf("\nThe Multiplication table of 5 is:\n");
for(i=1;i<=20;i++)
printf("%d",a*i);
getch();
}
It will print upto 20.

What is the use of getchar?

gets()

Reads characters from stdin and stores them as a string into str until a newline character ('\n') or the End-of-File is reached.

The ending newline character ('\n') is not included in the string.

getchar()

Returns the next character from the standard input (stdin).

It is equivalent to getc with stdin as its argument. === ===

What are the functions of a special library?

mad people u dont have an answer an thats what i am looking for