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

How arrays must be handled in c plus plus?

If the array is static it can declared in the structure itself:

struct myArrayTag

{

int num[12]; // array of 12 integers (e.g., 48 bytes).

} myArray;

If it is dynamic then you must use a pointer and allocate the array outside the structure. You should also maintain a variable in the structure to keep track of how many elements the array currently has:

struct myBufferTag

{

int * array; // Pointer to array of integers.

int size; // Size of array (number of elements);

} myBuffer;

All the bitwise operators have the same level of precedence in Java true or false?

False:

highest precedence

& bitwise AND

^ bitwise XOR

| bitwise OR

lowest precedence

What is meant by single array?

A single dimensional array, or one-dimensional array, is a contiguous block of memory that contains one or more elements, each of which can store a single fixed-width value. Since each element is the same length (in bytes), the total memory consumed by the array is equal to the product of the element length and the total number of elements.

One-dimensional arrays can be thought of as being a single row or column of numbered pigeon holes (the elements), such that each hole may contain a single object (a value). The numbers identifying each element are a zero-based incremental subscript, or index number. Thus for an array of n elements, the indexes will be in the range 0 to n-1. Some languages permit the first index to be offset from 0 such that the indexes will be in the range offset to offset+n-1, however this does not alter the actual index which is always zero-based.

Arrays permit random, constant-time access to any element in the array via the element's index. When accessing an element, the return value is a reference to the first memory address of that element. This is achieved through simple pointer arithmetic, such that element i will be found at memory address (i-1) x (size of element) bytes from the start address of the array (hence the index is always zero-based, regardless of any offset that is applied).

The value's stored in the elements must be of the same intrinsic type, but can be variables or constants of any kind, including object references and pointer variables, even pointers to other arrays.

Multi-dimensional arrays are merely an extension of one-dimensional arrays, such that each element contains a reference to another one-dimensional array (each element of which may refer to yet another one-dimensional array, and so on). For instance, a two-dimensional array can be thought of as being pigeon holes arranged in rows and columns, such that every row has the same number of columns, and every column has the same number of rows. A three-dimensional array can be thought of as being a cuboid of pigeon holes. Although it's difficult to imagine a four-dimensional array in a three-dimensional space, the easiest way to think of it is as being a one-dimensional array where each element contains a three-dimensional array. More simply, a series of cuboids arranged in a row or a column.

Multi-dimensional arrays needn't reside in contiguous memory, however each individual one-dimensional array that makes up a multi-dimensional array must itself reside in contiguous memory.

Accessing the individual elements of a multi-dimensional array requires one subscript per dimension. Thus for a cuboid that has 3 rows, 3 columns and 3 tiers, the middle box will be found at zero-based index (1, 1, 1). Again, simple pointer arithmetic is employed to determine the address of the element offset from the starting address of each one-dimensional array.

How do you resolve ambiguity in multiple inheritance?

Use virtual base classes. It is best if the common base class has no member variables and all member methods are pure-virtual. The multiple-inheritance class must provide all the implementation for the pure-virtual methods, even if the direct bass classes also provide their own implementations.

When should use a while loop over a do loop?

Generally speaking a for loop looks like this:

for(Initialization;condition;increment)

{

Do Stuff

}

whereas a while loop looks like this:

while(condition)

{

Do Stuff

}

Before the while loop there should be some initialization and somewhere in the Do Stuff section there should be statements that change the condition. Those statements are analogous to the increment section of the for loop.

What is an essential of Object Oriented Programming?

The 3 essential concepts of Object Oriented Programming are:

  1. Inheritance
  2. Encapsulation &
  3. Polymorphism

What are the functions of a database program?

Functions of a DB programIn it's most basic form, a database program must be able to add, delete and edit records in the tables which make up the database and also to search for specific records in the tables by using different search criteria. Also, in most cases, user authentication is required.

Function of Database

Indexing

Views

Security

Intergrity

Cocurrency

Backup and Recovery

Desing

Documentation

Update

Query

What is micro and how it is different from c variable name?

A macro is a variable that has a constant value throughout the program whereas a C variable is an identifier whose value can differ from function to function, it can be incremented or decremented whereas the value of a macro remains same .

Write a program for area of square in c?

This smells like homework, so I won't give you any actual code. Rather, I'll give you some pseudo-code for the function that returns the area:

calcarea (decimal width, decimal length)

return width * length

P.S., jeez, it's not that hard to do your homework, is it?

What is use of sorting algorithm?

sorting means arranging a list of numbers or elements in an order (ascending or descending).

How do you study programming?

There are amny tutorials on the web to do this. I would first look at what I wanted to concentrate on. Do you want to program for the web? games? business? be a hacker?. There are a lot of opportunities out there if one is willing to work. PHP and XML besides a good basis in C++ are good nowadays. Get yourself a good Linux distro like Ubuntu 7.04 or Fedora 7 and start playing around with shells and that will get you into the real programming world. Forget about windoze that old hack will soon wear out. The future is in Linux. Don't just take my word for it. My brother works for IBM (and has been a programmer for over 40 years, goes back to the days of punched cards, if anybody remembers that) and he says the same thing.

What is the difference between c plus plus and perl language?

Borland C++ was the successor to Turbo C++ and primarily included a better debugger. The product was later renamed Borland C++ Builder before Borland divided the company and passed all development systems to their CodeGear subsidiary, which produced CodeGear C++ Builder. However, all CodeGear products are now owned by Embarcadero Technologies, thus Embarcadero C++ Builder is the latest incarnation.

How do you declare an int array?

we define the array is

Array array[]={1,2,3,4,5} this is the integer Array

Array array[]={"apple","banana","carrot","mango"} this is the String Array

Using do while statement write cprogram for factorial number?

The program goes as follows:

#include

#include

void main()

{

int i, j=1;

printf("Enter the value of the integer whose factorial has to be calculated");

scanf("%d",i);

while(j

i = i*(i-1);

i--;

printf("The factorial of the integer is:%d",i);

getch();

}

OTHER METHOD.............

#include

#include

void main()

{

int n,f;

f=1;

printf("Enter the number:\n");

scanf("%d",&n);

while(n>0)

{

printf("%d",n);

f=f*n;

n--;

}

printf("The factorial of the integer is:%d",f);

getch();

}

another method

A very easy method,,,,,,

these is the work of 2nd year high school programming........... CVHS..

#include

int main()

{

char m;

int ans, i, n;

i=0;

m='y';

while((m=='y')(m=='Y'))

{

cout<<"Input a number ";

cin>>n;

if(n==0)

{

ans=1;

cout<<"The factorial of a number is "<

}

else

{

ans=1;

for(i=1;i<=n;i++)

{

ans=ans*i;

}

cout<<"The factorial of a number is "<

}

cout<<"\n Do you want to continue? (Y/N) ";

cin>>m;

}

return 0;

}

see,, its very easy!!!!

my new mathod

#include

#include

main()

{

int i,j,div,mod;

clrscr();

printf("enter any number = ");

scanf("%d",&i);

for(j=1;j<=i;j++)

{

mod=i%j;

if(mod==0)

{

printf("%d*",j);

div=i/j;

i=div;

j=1;

}

}

if(j==i)

{

printf("%d",i);

}

getch();

}

Write a c program to find the students details using structure?

#include //#include #define STU 3 #define SUB 3 void main() { int k,i; struct student { int rno; char name[20]; int marks[2]; int total; float avg; }sk; for(k=1;k<=STU;k++) { printf("Enter the roll no and name of the student %d:",k); scanf("%d%s",&sk.rno,&sk.name); printf("Enter the marks:"); for(i=0;i"%d",&sk.marks[i]); sk.total=sk.total+sk.marks[i]; } sk.avg=sk.total/SUB; } printf("\nRollno\tName\tMarks\tTotal\tAvg\n"); for(k=1;k<=STU;k++) { printf("%d\t%s\t",sk.rno,sk.name); for(i=0;i"%d ",sk.marks[i]); printf("%d\t%.3f\n",sk.total,sk.avg); } //getch(); }

When float used and when int used in C programming?

if your calculation involves a decimal point, u must use float, otherwise you can use integer for normal purpose.

for example,

if u want to divide some number, lets say 9/4 then u must use float to get the answer in accurate decimal point , otherwise if u use int there, the answer will be just 2 instead of 2.25

whenever we used an integer in the program we used int. if there is any decimal part in the number then we used float.

How much does a programming language generally cost?

Many programming languages, such as Java, are completely free to use, and being one of the major players in the programming language wars, as well as being cross-platform, in addition to being easy to learn, and in addition to it being free, many choose Java for their first language.

Another question: your question makes no sense: you cannot buy or sell programming languages.

What is a program written in high level language called?

the program written in high level language is called "source program"

What does it mean to be in the loop?

If somebody was to be out of the loop, they would be lacking critical information or popular knowledge. Now if somebody was IN the loop, this would mean you are up to date on the latest topics of your "loop".

What is the main functions of HRM?

There are seven main functions of HR . They are : Function 1: Manpower planning Function 2: Recruitment and selection of employees Function 3: Employee motivation Function 4:Employee evaluation: Function 5:Organizational relations Function 6: Provision of employee services Function 7: Employee education, training and development Functions and Activities of HRM

In order to achieve the objectives of an organisation, the HRM section or department must carry out a number of functions. The key functions of HRM can be summarized as the acquisition, maintenance, development and termination of employees.

Acquisition: This is the 'getting' phase of HRM. It includes estimating both the future demand and supply for human resources and integrating these resources into a total human resource strategy. In other words, the objectives and future directions of the organisation must be known before any reliable forecasts of people needs can be made. The acquiring process includes recruiting, selection and the socialization or induction of new employees.

Maintenance This is the 'keeping' function and involves providing benefits, services and working conditions that are needed if individuals are to remain committed to the workplace.

C program for polynomial multiplication?

/*==========================================

calculation of product of two matrix........

written by kr.gauraw

==========================================*/

#include<stdio.h>

#include<conio.h>

void main()

{

int mat1[3][3],mat2[3][3],mat3[3][3],i,j,k,sum;

clrscr();

printf("\nEnter values for 1st 3 x 3 matrix:\n");

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

{

for(j=0;j<3;j++)

{

scanf("%d",&mat1[i][j]);

}

}

printf("\nEnter values for 2nd 3 x 3 matrix:\n");

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

{

for(j=0;j<3;j++)

{

scanf("%d",&mat2[i][j]);

}

}

printf("\nThe 1st matrix you entered is :\n");

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

{

for(j=0;j<3;j++)

{

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

}

printf("\n");

}

printf("\nThe 2nd matrix you entered is:\n");

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

{

for(j=0;j<3;j++)

{

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

}

printf("\n");

}

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

{

for(j=0;j<3;j++)

{

sum=0;

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

{

sum=sum+mat1[i][k]*mat2[k][i];

}

mat3[i][j]=sum;

}

}

printf("\nThe product of two above matrix is:\n");

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

{

for(j=0;j<3;j++)

{

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

}

printf("\n");

}

printf("\n\n\nPress any key to exit.....");

getch();

}

What are the applications of parallel processing?

In a nut shell. The most common applications of parallel computing/processing are solving extremly complex problems whithin the science and engineering communities e.g. ... grid computing and internet technology.