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

Program in C to find root using bisection method?

#include

#include

#include

#define fn(x) (x*x*x-3*x*x-x+9)

void main()

{

clrscr();

float x,a,b,y,y1,y2;

cout<<"enter the initial value a&b"<

cin>>a>>b;

y1=fn(a);

y2=fn(b);

if(y1*y2>0)

{

cout<<"invalid interval"<

}

do

{

x=(a+b)/2;

y=fn(x);

if(y1*y<0)

{

b=x;

y2=y;

}

else

{

a=x;

y1=y;

}

}

while(fabs(b-a)>.001);

cout<<"the root of the equation ="<

getch();

}

Which application developed by c?

All kinds of machine-based programs can be developed in C, including: operating system kernels; low-level drivers; embedded systems software; client-server applications; general purpose applications; utilities; and games. There is no real limit to what you can develop in C. The question is really about whether C is the best choice for the type of software you wish to develop. For purely low-level development it is ideal, but for mid-level to high-level developments you'd be better off with C++. Where performance and memory are not a major issue, Java is better for application development.

What type of loop uses a boolean expression?

A "while" loop is appropriate in this case - one in which the condition is evaluated at the beginning of the loop.

What are arrays?

  • Array data structure, an arrangement of items at equally spaced addresses in computer memory
  • Array data type, used in a programming language to specify a variable that can be indexed
  • Associative array, an abstract data structure model that generalizes arrays to arbitrary indices

or various kinds of the above, such as

  • Bit array or bit vector
  • Dynamic array, allocated at run time
  • Parallel array of records, with each field stored as a separate array
  • Sparse array, with most elements omitted, to store a sparse matrix
  • Variable-length array
  • Ragged (jagged) array, where the rows have different lengths individually

or various related concepts:

  • Array processor, a computer to process arrays of data (not to be confused with a processor array)
  • Array programming, using matrix algebra notation in programs (not the same as array processing)
  • Array slicing, the extraction of sub-arrays of an array
  • APL (programming language)

or also:

  • Video Graphics Array (VGA), a display adapter and video format, and many variants thereof (EVGA, FWVGA, QVGA, QXGA, SVGA, SXGA, SXGA+, TXGA, UVGA, XGA, XGA+, ...)

What is the difference between a constant and a variable in java programming language?

A constant in Java is defined using the "final" modifier. For instance:

final double Density_Of_Water = 1.000;

would set Density_Of_Water to 1.000. This value can not be modified throughout the program because "final" told the compiler that this value would not change. A variable however, can be changed by the user throughout the program.

Write a program for scrolling a text in status bar using JScript?

Wrote this a few years ago, just paste it in the head or import it from a js file.

pretty self explanatory

<script language="JavaScript">

//Author: fjhdehoog

//Scriptname: Slide in status

var MyStatus='This is an example of how to use javascript to make a scrolling status text';

var start_status=1000; //start in 1 sec

var TBD=100; //Time Btween Digits 1000 = 1 Sec

var LoopIt=1; // 0= dont loop -- 1= loop

var DFSF=10000; //Display full status for 10 Sec /*------------------------------------------*/

setTimeout('ScrollStatus()',start_status); //comment this line out if u want to use body onload or window.onload

CurNum=MyStatus.length;

function ScrollStatus(){

window.status=MyStatus.substring(CurNum);

if (CurNum!=0) {

CurNum--;

setTimeout('ScrollStatus()',TBD); }

else

{

if (LoopIt) {CurNum=MyStatus.length;

setTimeout('ScrollStatus()',DFSF);} else { /*do Nothing*/ } } }

</script>

How do you make computer virus using c language?

Computer viruses can be written in any programming language, not just C. C would be a common language for a virus to be written in because C is fast, and allows viruses to directly access lower level functions like computer memory. C has also been a very popular language for many programs in the past, so those who decide to write a computer virus would be familiar with that language already.

How do you find the greatest of two numbers without using the if-else comparison operators?

By subtracting any two of the numbers A-B , if the output number is negative , B IS GREAT and if its positive A is great

What is the expansion of conio.h?

EXPANSION OF CONIO.H

Conio.h library in C implies a console version which encapsulates the common I/O functions.

Console input/output header

How do pointer work in c program?

Pointer can be defined as variable that is used to store memory address , usually the location another variable in memory. Pointers provide a means through which memory location of a variable can be directly accessed.

Why isn't main a keyword in c?

Neither is printf, stderr or NULL. Certainly, they are important words, but not keywords.

C plus plus program for 1223334444..?

int n, i;

for(n = 1; n <= 5; ++n) {

for(i = 1; i <= n; ++i) { printf("%d", n);

}

}

When using a For loop what happens when the loop variable is equal to the final value?

That would depend on how exactly you define the three parts of the for loop. A typical for loop, equivalent to "for i = 1 to 10" in other languages, would look like this:

for (int i = 1; i <= 10; i++)
{
...
}

If you change this to:

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

then the code would still execute once.

What is program documentation?

Program documentation is an essential part of any computer program or application. The documentation specifies what each part of the code does, what events will be triggered during the course of the program, and makes sure that no part of the program is accidentally left off the interface or code.

What is the real world example for linked list?

If you are referring to the Linked Lists used in programming:

You can use the Linked lists you learn in c++ (for example) to define actual shapes in OpenGL (a graphics library), then just 'call' the shapes and apply transformations to them (moving them around, rotating, etc).

This method saves a lot of bandwidth between your CPU and video card as the shapes are defined already.

Hopes this answers your question

Write a programm to check whether a matrix is upper triangular or lower trianglular?

#include<iostream.h> #include<conio.h> # define n 10 void main( ) { int mat[n][n]; int d; // Input elements cout<< "\n Enter dimension of square matrix:"; cin >> d; for(int i = 0; i < d ; i++) for( int j = 0; j < d ; j++) {cout<<"\n Enter elements for "<< i+1 << "," << +1<"location :"; cin >> mat[i][j]; } clrscr(); //Print the array cout<<"\n The Original matrix : \n\n"; for( i = 0; i < d ; i++) {for( j = 0; j < d ; j++) cout<< mat[i][j]<<"\t"; cout<< "\n"; } //upper half of left diagonal..... cout<<"\n The Upper half of the matrix : \n\n"; for( i = 0; i < d ; i++) { for( j = 0; j < d ; j++) { if(i < j) cout << mat [i][j] << " " ; else cout << " " << " "; } cout << "\n "; } //lower half of left diagonal..... cout<<"\n The Lower half of the matrix : \n\n"; for( i = 0; i < d ; i++) { for( j = 0; j < d ; j++) { if(i > j) cout << mat [i][j] << " " ; else cout << " " << " "; } cout << "\n "; } getch ( ); }

How do you convert octal digits into three binary digits?

C++ does not support octal encoding within source code (only decimal and hexadecimal are supported), so the octal must be represented with a string. The binary output must also be a string. Every octal digit represents three bits of binary, thus the binary output string will always be three times the length of the octal input string.

The loop will begin with the octal character at index 0 and work through each character from left to right. On each iteration, the binary output string will be appended with a 3-character string, as follows:

octal = binary

"0" = "000"

"1" = "001"

"2" = "010"

"3" = "011"

"4" = "100"

"5" = "101"

"6" = "110"

"7" = "111"

Thus octal input "437" will begin with the "4" producing an output of "100". On the next iteration, "3" will append "011" to produce "100011". On the final iteration, "7" will append "111" to produce "100011111".

What is the function of the instruction counter?

There is no such thing as an instruction counter. You are either referring to the instruction register (IR) or the program counter (PC), The PC is more commonly known as the instruction pointer (IP). The IR and IP work together.

The IR fetches the instruction currently pointed to by the IP which is then incremented to refer to the next instruction. The IR is then decoded and executed and the cycle repeats ad infinitum (known as the fetch-decode-execute cycle). However, if the fetched instruction is a control transfer instruction (such as JMP), its execution will cause the IP to refer to another address which, in turn, causes execution to "branch" to a new section of code on the next fetch-decode-execute cycle.

Note that a low-level JMP is equivalent to a goto statement in high-level code, however code can also branch through high-level if and switch statements as well as structured loops such as for, while and do-while statements.

What is the format specifier use with the data type double in c language?

double would be %e, %f or %g (depending on the format you want), long int would be %ld or %lu (signed or unsigned), long double would be %Le, %Lf or %Lg.

When would you use a count controlled loop vs. a flag controlled loop?

Counter Loop:

Counter loop is a loop which executes statement up to a fixed number of time.

In GW FOR ... NEXT loop is used as counter loop.

Controlled Loop:

Controlled loop is used to extend the statements till a specific condition is satisfied. In GW WHILE ... WEND is used as controlled loop.

What does GUI interfaces mean?

Graphic User Interface. One of the main uses is so that you can use a mouse to interact with your computer. The system lays out your screen as a grid and "knows" where the cursor is and where your icons are with respect to that grid. When you "click" your mouse button, the computer checks the cursor's location and compares it to the graphic objects(such as icons) and does whatever action it is programed to do. For example if you hover the cursor over the icon for Internet Explorer and double-click(in Windows), the computer starts your IE browser.

What is best and average case of binary search?

Merge sort is O(n log n) for both best case and average case scenarios.

How do you convert a character into its ascii value?

In C a character already is its ASCII value:

char c= 'A';

printf ("%c is %d (0x%x hexa)\n", c, c, c);