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 Write a c program to find and replace a string in the given text?

  1. #include
  2. # include
  3. char c1,c2,a[80];
  4. void main()
  5. {
  6. clrscr();
  7. find_rep();
  8. getch();
  9. }
  10. void find_rep(void)
  11. /* Function to find & replace any text */
  12. {
  13. char c1,c2;
  14. char a[80];
  15. int i,j,k;
  16. printf("Enter a line of text below:-");
  17. printf("Press Enter after line..");
  18. printf("You Have Entred:- ");
  19. gets(a);
  20. printf("Enter the replaceable & replacing letter respectively:- ");
  21. scanf("%c %c %c",&c1,' ',&c2); //i have given space & 2nd %c
  22. for (j=0;j<80;j++)
  23. {
  24. if (a[j]==c1)
  25. a[j]=c2;
  26. }
  27. puts(a);
  28. printf("Here all %c are replaced by %c.", c1,c2);
  29. return;
  30. }

When a function does not return a value what kind of function is it called?

In most computer languages, a procedure that returns a value is called a function and a procedure that does not return a value is called a subroutine or subprogram. Usually the languages treat the passing of arguments/parameters differently between functions and subroutines.

The C language does not distinguish between them. A subroutine that does not return a value is define as a "void" function indicating that no return value is used or available.

Which is better - AVL or Red Black Trees?

It depends on what the tree is being used for. If the tree is being used to store data that is not going to be modified very much, than AVL trees are probably better. In most other cases, I'd say Red-Black trees are better.

Why is an array of reference not possible?

Unlike pointer variables and other variables, references have no storage of their own. A reference is simply an alias for an object that already exists in memory (allowing you to refer to the object by its memory address). Since they have no storage of their own it is impossible to create an array of references. You can of course create an array of objects, each of which can then be referenced. You can also have several references to the same object. But you cannot store those references because there is nothing to physically store other than the object itself, which is already stored. For the same reason you cannot reference references nor can you point to references. You can only refer and point to objects (or point to NULL of course).

What does two asterisks mean in C?

It means to declare or dereference a pointer to a pointer. For example:

int x = 5;

int *xPtr = &x;

int **xPtrPtr = &xPtr;

printf("%d\n", **xPtrPtr);

The type of decimal that has a final digit?

The type of decimal that has a final digit is a Terminating Decimal!!! Hope you enjoy!

Write a c program to find eigenvalue of a matrix?

Yes, do write. That's what you always have to do when you have got a homework-program.

Write a program and check whether sim or not?

mvi c,ooh

lxi h,foooh

mov a.m

lxi h

add m

jnc

inr c

inx h

mov m,a

inx h

mov m,c

hlt

What are eterative statements?

Iterative statements are:

while (expr) statement

for (expr; expr; expr) statement

do statement while (expr);

How do you write a c program to calculate the circumference of the circle using macros with parameters?

// macro definitions:

#define PI 3.14159265358979323846

#define CIRCUMFERENCE(radius) (2. * (radius) * PI)

// use this as in CIRCUMFERENCE(21.34)

What is the Difference between attribute and property?

Here's my opinion:

Not much really; from a programming perspective I would say the following ...

Property: for example the length of a String i.e. String.Length Generally you do not set it

Attribute: for example the Value of a String i.e. String str = "a string" Generally you would set it

>>>>>>>>>>>>>>>

- attributes: are _given_ by the human to an object
- properties: are _natural_ aspects of an object.

amanpreet

Given a sorted array- 8 13 17 26 44 56 88 97. Using binary search method find the element 88. show the contents of high low and mid at each step?

The array has eight elements indexed 0 to 7. The middle element will be found at index (0+7)/2=3. Element 3 has the value 26, which is smaller than 88, so 88 must reside in the array starting at index 4 ending at index 7.

The array has four elements indexed 4 to 7. The middle element can be found at index (4+7)/2=5. Element 5 has the value 56, which is smaller than 88, so 88 must reside in the array starting at index 6 ending at index 7.

The array has two elements indexed 6 to 7. The middle element can be found at index (6+7)/2=6. Element 6 has the value 88. Thus 88 was found at index 6.

What is the C code for triangle asterisk?

HERE IS THE CODE FOR C++ 2010

#include <stdio.h>

int main ()

{

int i,j;

char prnt='*';

for(j=0;j<10;j++){

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

printf("%2c",prnt);

}

printf("\n");

}

return 0;

}

 

Why C language is preferred for computer graphics programs?

C is one of the powerful languages designed yet.even though C language is

superceeded by many new languages like c++,java,c# but the importance of c is still

unchallenged.

especially c is the ultimate choice where the performance is the ultimate criteria and

the resources are very scarce like your embedded systems.in those areas your code

should run fast and should be small.perhaps in those apllications C is the ultimate

choice.

even now when it comes to performance(speed of execution) nothing beats c not even

c++.c++ will unnecessarily create havoc with its oops features when we use it as a

system programming language.that is the reason why still c is unbeatable in the

system programming world and even the legends like linus tovarlds preferrde c to c++

for implementing Linux kernel. c will not die like any other language as some may die

due to competition.

comming to ur question why c is preferred for computer graphics and games?the

answer is simple because of its speed .for example u are playing a game where u need

to shoot with a machine gun the opponents.if u press the key on ur keyboard the ascii

code for that key should be generated and supplied to the routine that handles the

functionality of that key and shoot.But imagine what happens if ur gun fires after 2

secs or 3secs after pressing the shoot button.wont ur game become a boring task?

under such situations c scores over other languages as it is the language which can

produce the code that runs many a times faster than the code produced by any other

language.

I hope u got some idea why c is prefferd over other languages in graphics and games

phani Krishna (Mtech jntu)

What is a file pointer?

A file pointer is an opaque object that refers to a file. Opaque means that you should not attempt to delve into its specific value, other than to use it as a file pointer. FILE *fp; /* fp is the file pointer */ fp = fopen("somefile.txt"); if (fp == NULL) ...{exception}... fprintf(fp, "Hello somefile.txt"); fclose(fp);

A 10-bit code could represent how many characters?

210 = 1024, so there are 1024 different bit configurations in a 10-bit code.

What is an unclosed string literal?

The error "unclosed string literal" means that you wrote a double quote " somewhere but you didn't write another double quote later on to close the string.

Note: You cannot start writing a string on one line and continue on another line, like this:

System.out.println("Hello

World");

If you absolutely want to distribute this over multiple lines, do it like this:

System.out.println("Hello "

+ "World");

What are the different types of discourse?

There are four major types of discourse. These major types of discourse include argumentation, narration, description, as well as an exposition.

How do you convert decimal to binary of real values?

This is the Binary32 format from IEEE-754-2008.

To convert a decimal to binary real start by checking for zero. If so, the answer is all zeroes. Then record the sign and make the number positive. Then create an exponent with an initial value of 127. Iteratively multiply or divide the number by two, while decrementing or incrementing the exponent, until the number is greater than or equal to 1, and less than 2. Throw away the high order bit, by subtracting one from the number, as it will always be one, and we can imply it in the result. Multiply the number by 223, and add 0.5, to construct a rounded integer mantissa of 23 bits in length. Assemble the sign bit, 8 bit exponent, and 23 bit mantissa together. Note that exponents of 255 and 0 are special and are interpreted differently, so the proper range of exponent is 1 to 254.

For more information, please see the Related Link below.

For more information of other formats covered under the specification, please see the second Related Link below.