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

2 types of identifiers in C programming language?

1. identifiers beginning with a letter

2. identifiers beginning with an underscore

How to program set Cardinality in C plus plus?

The cardinality of a set is simply the number of elements in the set. If the set is represented by an STL sequence container (such as std::array, std::vector, std::list or std::set), then the container's size() member function will return the cardinality.

For example:

std::vector<int> set {2,3,5,7,11,13};

size_t cardinality = set.size();

assert (cardinality == 6);

What data type is a percentage?

Percentage is not a data type. A percentage of something would need a floating point data type to store it. One of the following data types.

float

double

long double (in gcc, not sure about other compiler systems)

What are the importances of linked list and its real-world application?

Outside of academia I do not think linked list are important, a btree is important.

As for a real-world application, I do not recall one. I did use a linked list back in the days of the Apple 2/Commodore 64 but That was before hard drives (were affordable) and before I got my hands on btree source code.

What does hook mean in programming language?

A hook is a method of interposing a piece of code in front of another piece of code, so that the first piece of code executes before the second piece of code, giving the first piece of code an opportunity to monitor and/or filter the behavior of the second piece of code. An example might be a mouse hook, allowing the hook code to monitor the mouse while at the same time preserving the functionality of the original mouse event processing routine.

Which function is used to read data from the console?

The scanf() function in the <stdio.h> C standard library header.

What are the main uses of the Healthcare EDI program?

Healthcare EDI Solutions program has two main uses; firstly, it provides Chain Management (CM) and secondly, it also provides health care EDI technology claims management and Patient Information Exchange (PIE).

How can you use for loop when the number of iterations are not known?

It doesn't matter if you know the number of iterations or not, the for-loop is the same. Here is an example:

for (leave= 0; ! leave; ) {

/* read from file, on EOF set leave= 1; */

}
Yes. The for loop is not constrained to be used for simple counting tasks. You can, for example, have the control variable be a pointer an walk it through a tree. All you need to know is that the loop expression is executed at the end, followed by the test expression. Nothing in the spec says these have to be integer counting variables.

How are the data elements of a structure accessed and processed explain?

The data elements of a structure are laid out according to the order they are declared. Padding bytes may also be inserted between members to ensure all members are correctly aligned. Memory alignment can be user-defined, however it's generally better to align objects according to the underlying architecture. For instance, on a 32-bit system the underlying architecture has a 4-byte word length, thus an object that is equal or greater in length is best aligned upon a 4-byte boundary to keep memory access cycles to a minimum. Types that are smaller than the word length are usually aligned so that they do not cross a word boundary, such that a single 4-byte word can store 4 char types, 2 shorts, or 2 chars and 1 short. If the total size of the structure crosses a word boundary, padding bytes are inserted after the final member so the total size is an exact multiple of the word length. However, if the total size is less than a single word length to the extent that two or more structures may fit within a word, no padding bytes are required.

Given that each structure member is positioned at a constant zero-based offset from the start address of the structure, the compiler can use trivial pointer arithmetic to access the individual members of an instance of the structure, just as easily as it can calculate the address of an array element from its zero-based suffix (index).

How do you write a c plus plus program to display n congratulatory messages where n is a user input value?

#include<iostream>

#include<sstream>

int main()

{

unsigned num;

while (true)

{

std::cout << "Enter a number: ";

std::string input;

std::cin >> input;

std::stringstream ss;

ss << input;

if (ss>>num) break;

std::cerr << "Invalid input.\n";

}

for (int i=0; i<num; ++i)

std::cout << "Well done!\n";

}

You use this to get a sum?

Sorry, use what?

"Addends" are what you add together to get a sum.

Call by value in c programming?

Its way of passing arguments to a function.In this method the value of actual arguments(the arguments in the function call)remains unchanged. changes that we make are effected only to the formal arguments.

eg.

#include void modify(int,int);// function prototype. this is given to make the compiler aware that there is a function modify. if we didnt do this a error will be shown. otherwise the function body should be written before the function call

main()

{

int a,b;

printf("enter two numbers");

scanf("%d %d",&a,&b);

modify(a,b);// function call the parameters a and b are actual arguments.

printf(" a and b in the main %d and %d",a,b);

}

void modify(int a,int b)// function header the parameters no1 and no2 are called as formal arguments.

{

a=a*3;

b=b*3;

printf(" a and b in function %d and %d",a,b

}

output:enter two numbers

3

2

a and b in function 9 and 6

a and b in the main 3 and 2.

this is a program to multiply 3 to the numbers given by the user . here we use function and the arguments are passed by call by value method.here the value of the formal arguments are altered withinthe function but no change happens to the actual arguments . the values in the main does change even after the function call.

Why does a 93 Caprice engine seem like the fuel shuts off at times and run great other times?

My 93 Caprice started with a significant hesitation, that eventually morphed into a no run condition. I replaced the distributor cap and rotor, ignition module, ignition coil, fuel pump and fuel filter all to no avail. I had to have the car towed into a repair facility where they diagnosed the problem as a faulty pickup coil (located on the distributor shaft below the plate where the ignition module mounts. The car hasn't quit running since. Good Luck! Start with the fuel filter, either on the firewall or in the fuel line under the car. Do you have water in the gas? Are your injectors clean? Are your air filter, PVC valve clean? A lot more info required here. try the map sensor , it can be a vaccuum leak and not the fuel at all . If this doesn't solve the problem you should try the control module . Most modules when bad seem like the fuel is cutting off when actually it is the spark . The in-line fuel filter under the driver's side of the car may be dirty or clogged. Be careful replacing it b/c it spurts gasoline for a couple seconds. Keep track of the fuel guage also, if it is less than half (usually a quarter tank) and this symtom occurs, the fuel pickup in the fuel tank can be off by this much and the fuel will slosh in the tank and not stay under the pickup hence the cutoff of fuel symptom. Occurs on hard left corners when all the fuel flows to right,due to pickup orientation. The in tank baffle can break (there glued on the plastic ones)and cause this also. The harder the left, the more the cut off of fuel to the point of stalling the motor. Replacing the fuel pump and sender and/or fuel tank would be the cure if this proved to be the reason. I also keep my 91 at least half full of gas because of the known issue of poor baffleing on the stock plastic tanks, guess they never figured anyone was gonna put a performance suspension and 450 HP in one eh... lol One other thing needs to be considered with this type of problem is that after about 75,000 miles the throttle body develops a fairly significant carbon build up. You can clean it yourself or a Chevy dealer will clean it for under $200. If you choose to clean it yourself I recommend you spend some time at a junkyard and practice on one of their cars so you have an idea of what you are getting into. VBD Could be an electrical connection. I though my problem was fuel oriented too, but worked great when I fixed a similar sounding problem by replacing the distributor cap/rotar. Ran great and smooth afterwards. Startup better too.

In my system C language does not support for fullscreen mode why?

Your question has nothing to do with C language, it's about your Windows' DOS-compatibility (or incompatibility).

Implementation of LZW compression algorithm in C?

{

unsigned char **dict;

int *dlength;

unsigned char p[80], temp[80];

char c;

int plength,i,j,k,diff,cd;

plength=1;

cd=256;

p[0]=EOF;

dict= (unsigned char *)malloc(99999); //Allocating memory for Dictionary

if(dict == NULL)

printf("Unable to allocate memory \n");

dlength=(int *)malloc(99999);

for (i = 0; i < 99999; i++) {

dict[i]=(unsigned char *)malloc(60);

if(dict[i]==NULL)

printf("Unable to allocate memory \n");

}

for (i=0;i<256;i++) //loading dictionary with ASCII set

{

dict[i][0]=i;

dlength[i]=1;

}

while ((c = fgetc(Fpt)) != EOF)

{

if(cd==256)

p[0]=(unsigned char *)c;

diff=0;

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

{

for (k=0; k<plength; k++) //checking to see if p+c in dict

{

if(dict[i][k]!=p[k])

diff=1;

}

}

if (diff==0)

{

p[plength]=(unsigned char)c;

plength++;

}

if (diff==1)

{

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

{

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

{

if(dict[i][k]!=p[k])

diff=1;

}

if (diff==0)

j=i;

}

fputc(j, outfile);

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

{

dict[cd][i]= p[i];

}

dict[cd][plength]=(unsigned char)c;

cd++;

p[0]=c;

}

}

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

{

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

{

if(dict[i][k]!=p[k])

diff=1;

}

if (diff==0)

j=i;

}

fputc(j, outfile);

fclose(outfile);

fclose(Fpt);

}

By Amit Setia

Write a program in java on Crytography?

/*Input: Enter the String: AHFJFJ

* Enter the gap : 2

*Output: CJHLHL

*/

import java.io.*;

class Crypt

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the String: ");

String s=in.readLine(),s1="";

System.out.print("Enter the Gap: ");

short g=Short.parseShort(in.readLine());

for(short i=0;i<s.length();i++)

{

char ch=s.charAt(i);

if(Character.isUpperCase(ch))

{

ch+=g;

if(ch>'Z')

ch-=26;

else if(ch<'A')

ch+=26;

s1+=ch;

}

else if(Character.isLowerCase(ch))

{

ch+=g;

if(ch<'a')

ch+=26;

else if(ch>'z')

ch-=26;

s1+=ch;

}

else if(Character.isDigit(ch))

{

ch+=g;

if(j>'9')

j-=10;

else if(j<'0')

j+=10;

s1+=ch;

}

else

s1+=ch;

}

System.out.print("String: "+s1);

}}

What do you mean by a static function?

In Java, a static function is not attached to a particular object, but rather to the whole class.

For example, say we have the following class:

class Song {
String song;

void printSong() {
System.out.println(song);

}

static void printStaticSong() {
System.out.println("This is a static song. It has no tune.");

}


}

The static function Song.printStaticSong() can be accessed without creating an instance of the Song class (using the "new" keyword)

However it cannot access the members of Song (such as song), since it is not an instance of that object.