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

Similarities between struct and union?

Struct and Union have following similarities:- Both are aggregated data types that allow a mixed for values to be contained in their instances.They are the way aggregation is done in C for making. The difference between them is that union allows the different items to be in it but allows access to be on one becase they are represented in overlapped manner. A Struct is also aggregation but it separates each data item contained in it and therefore anyone can be accessed anytime from its instance variable.Unions are ordinarily used because of performance and generalization ,while the structures are generally used for aggregation. For queries Rupesh Kumar Joshi ,rupesh_joshi@sify.com

Write aprogram in c to calculate the cube of given integer number using function prototype?

#include <stdio.h>

int findcube(int); // prototype

int main()

{

int a,b;

printf("Enter a number: ");

scanf("%d",&a);

b=findcube(a);

printf("The cube of %d is %d\n",a,b);

}

int findcube(int x)

{

return x*x*x;

}

What is the need of deque?

A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion). So when we need to insert or delete at both end we need deque.

State and explain any 4 predefined data types in C plus plus programming?

A char is always 1 byte long, but may be signed or unsigned depending on the implementation. Explicitly signed or unsigned char types are treated as being independent types from the implicit char type (3 separate types).

A short (or short int) is at least 2 bytes long while a long (or long int) is at least 4 bytes long. Both are implementation-dependent with regard their actual size and sign, but, like char, may be explicitly signed.

Char, short and long are used to store integers (whole numbers). A char can store signed values in the range -128 to +127, or unsigned values in the range 0 to 255.

A double is at least 8 bytes long while its shorter counterpart, a float, is at least 4 bytes long. Both are implicitly signed, floating point values.

To determine the length of any type (including predefined types) us the sizeof operator.

What is the source code in C to convert Celsius to Fahrenheit?

#include<io.sys>

// Temperature conversion functions:

float celcius_to_fahrenheit (double c) { return c * 9.0 / 5.0 + 32.0; }

float celcius_to_kelvin (double c) { return c + 273.150; }

float fahrenheit_to_celsius (double f) { return (f - 32.0) * 5.0 / 9.0; }

float fahrenheit_to_kelvin (double f) { return celsius_to_kelvin (fahrenheit_to_celsius (f));

float kelvin_to_celsius (double k) { return k - 273.150; }

float kelvin_to_fahrenheit (double k) { return celsius_to_fahrenheit ( kelvin_to_celsius (k));

int main (void) {

double c, f;

scanf ("Enter a temperature in Celsius: %f", c);

printf ("%f Celsius is equal to %f Fahrenheit\n", c, celcius_to_fahrenheit (c));

return 0;

}

Which type of data is used to explain a relationship?

A foreign key constraint is used to represent a relationship in a RDBMS (relational database management system).

Difference between BufferedWriter and FileWriter in java?

A newLine() method is provided, which uses the platform's own notion of line separator as defined by the system property line.separator. Not all platforms use the newline character ('\n') to terminate lines. Calling this method to terminate each output line is therefore preferred to writing a newline character directly, FileWriter doesn't have this feature. ALso BufferedWriter are fast as they write to buffer first before writing to file

Substring in c without string functions?

#include #include intsearch(char[],char[]); void main() { char a[100],b[40]; int loc; printf("\n Enter the main string :"); gets(a); printf("\n Enter the search string :"); gets(b); loc = search(a,b); if(loc==-1) printf("\nNot found"); else printf("\nFound at location %d",loc+1); getch(); } int search(char a[],char b[]) { int i,j,k; i=0,j=0; while(a[i]!='\0') { while(a[i]!=b[0] && a[i]!='\0') i++; if(a[i]=='\0') return(-1); //search can not continue k=i; while(a[i]==b[j] && a[i]!='\0' && b[j]!='\0') { i++; j++; } if(b[j]=='\0') return(k); if(a[i]=='\0') return(-1); i=k+1; j=0; } }

Why wr are using c programming?

C/C++ is used to write system softwares. The whole of UNIX operating system is written in C language.

Program in c to get the sum of n numbers present in an array using one dimensional array?

#include<stdio.h>

#include<conio.h>

main()

{

int num, n,sum=0,i=0;

printf("enter the number of elements to be added ");

scanf("%d",&n);

printf("enter %d numbers",n);

while(i<n)

{

scanf("%d",&num);

sum=sum+num;

i=i+1;

}

printf("the sum of %d numbers is %d",n,sum);

getch();

}

When you use Visual C plus plus which window do you use to change the attributes of a form?

There should be "Properties" window. If you do not see, you can make it visible if you go to "View"-> "Properties".

What is a global declaration?

A global declaration of a function or variable is a declaration that is at the global scope of the program, not inside another function. This means that the name will be visible within all functions in the program.

What is type c gypsum board?

Type C gypsum board meets and exeeds the fire resistance requirements of a type x board. It has mineral additives in the gypsum core that expands when exposed to heat. This expansion holds the board together longer during fire exposure. It is referred to by the Gypsum Association as "Improved Type X" board.

Write a program in c that prompt user with following lines add two integers test an integer for odd or even and quit?

write a program in C that prompts the user with the following lines:

a) Add two integers

c) Compare two integers for the larger

t) Test an integers for odd or even

q) Quit

What are 3 world events between 428 B.C. - 347 B.C.?

Plato was born in 428 B.C. and died in 347 B.C. so that's got to count for two! :P

Limitations of queue in data structure?

A queue is a particular kind of collection in which the entities in the collection are kept in order and the principal operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed.

Some Applications:

1) Serving requests of a single shared resource (printer, disk, CPU), transferring data asynchronously (data not necessarily received at same rate as sent) between two processes (IO buffers), e.g., pipes, file IO, sockets.

2) Call center phone systems will use a queue to hold people in line until a service representative is free.

3) Buffers on MP3 players and portable CD players, iPod playlist. Playlist for jukebox - add songs to the end, play from the front of the list.

4) When programming a real-time system that can be interrupted (e.g., by a mouse click or wireless connection), it is necessary to attend to the interrupts immediately, before proceeding with the current activity. If the interrupts should be handles in the same order they arrive, then a FIFO queue is the appropriate data structure.

How do you write a c program to analysis a circuit?

There is no need to write a C program for circuit analysis; there are lots of packages out there that already do that (for example, Spice).

How to write a program that for all integers i j k and l from1 to1000 finds and prints all combinations of i j k and l such that i plus j plus k equals l and ijkl?

Some of ways to solve this problem is to use four nested loops for().
Something like following:
...
const int limit = 1000;
//some code here
for (int i(0); i <= limit; i++)
{
for (int j(0); j <= limit; j++)
{
for (int k(0); k <= limit; k++)
{
for (int l(0); l <= limit; l++)
{
if ((i + j + k) == l)
{
cout << endl << "i + j + k = l and equals to " << l << endl;

}

cout << "ijkl equals to " << (i*j*k*l) << endl;

}

}

}

}
...
//some code here

Write the program that will ask the user to enter a number of per side of a square and display its outline?

#include<stdio.h>

int main()

{

int side,area of square;

print f("Enter the length of side\n");

scan f("%d",&side);

area of square=side*side;

print f(the area of square is %d\n"area of square);

return 0;

}

Can include files be nested in c?

Yes, include files can be nested in C and C++. In fact, most library implementations do just that.

What is another term for a page file and what are they used for?

SWAP file. Sometimes it's called swap file like for Linus Sytems. You need a page file to save data when you are using your operation system. If don't have enough RAM OS doesn't have enough space in your memory to work properly. So, in such case OS uses a paging file. When you have 512 Mb or more in Windows Xp you can disable Paging file, which will accelerate your system at least a little bit.

What is meant by heap in c or cpp?

If you see the word "heap" in the context of C/C++ programming, it is probably referring to one of two ideas.

First, if it is written as "the heap", it is probably referring to dynamically allocated memory. We conceptualize memory as either being on "the stack" or "the heap" in main memory. Memory allocation from the heap happens when a call to malloc (or similar functions) are called in C, or when the "new" operator is used in C++. This is in contrast to statically allocated memory, which comes from the load module and is known at compile-time, or from the "stack" which is used at run-time to allocate local scope, or automatic, memory.

Another usage of the word heap is a certain data structure called a heap. It is a very common data structure for priority queues and is crucial to the famous HeapSort algorithm. You can easily find more information on this data structure e.g. by searching for HeapSort.

What is the TCP Reno algorithm?

TCP doesn't immediately acknowledge every single received TCP segment. If a

single segment is received it is necessary to wait for 100-200ms on the assumption

that the receiving application will probably generate a response of some kind. But

if there is delay in sending acknowledgement by the receiver then the network is

delayed.

What is C x C plumbing?

Cc in plumbing refers to the measurement from one object to another. Since plumbing is round the measurements are taken from "center to center".

What is the ASCII value of white space in c language?

int main (void) { printf ("space is %d\n", ' '); return 0; }