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

Compare break and continue statement?

Break - will force to terminate the loop you are in to the nearest outer block.

Continue - will force to skip the rest of the code in loop and take next iteration.

Break for example is not only limited to loop constructions, it is also used in switch statement in order to stop executing following cases (works as described above, jumps out of switch).

Write a c program that simulates ls command?

#include

#include

#include

#include

int main(int c, char *argv[])

{

DIR *ptr;

int i=0;

struct dirent *p;

ptr = opendir(“.“);

p = readdir(ptr);

if((c!=1) && (strcmp(argv[i]), “-a” 0 )

{ //child

execlp ( “/bin/ls”, “ls”, “-l”, NULL ); //execute ls

}

else

{ //parent

wait (NULL); //wait for child

printf(“\nchild complete\n”);

exit (0);

}

}

Difference between current and standard directory in c?

The 'current directory' is where you are in this moment, the 'standard directory' is where something usually is (quite vague definition, isn't it?)... for example, the standard directory for the apache configuration file is /etc/apache, for temporary files it is /tmp

What is hello world?

Hello world is the canonical program that all programming languages use to introduce new programmers to the language. The program simply prints the text "Hello world" via console output and helps programmers quickly identify the key difference in each specific language's implementation of that program.

What loop should no execute if the test expression is false to begin with?

for loop and while loop need the expression to be true for further execution of the program.

Which take a string as input and find its length?

strlen is the C library function that accepts a pointer to a char array and returns an integer specifying the number of characters (in bytes) of the array. This function is usually not used any more, because it does not support multi-byte characters, such as UTF-8.

What are the functions of variable attenuator?

Neither the C nor C++ languages specify variable attenuators. In engineering, an "attenuator" is something that reduces the amplification of a signal or other source. The closest C or any other programming language would come to such an operation is through the negative "-", divide "/" or bitwise-right ">>" operators.

If this is in reference to a library which interacts with a physical mechanism through C, you will need to refer to the manual for the library's API for further information.

How do find mode in C-Language?

#include <stdio.h>

main (){

int x;

printf("Hello World! with Prey's Haircut: ");

scanf("%d", x);

getch();

}

3R of a C?

three rings of a circus.

Q Is This Answer Supposed To Be A Joke!

What is the time complexity of radix sort?

If the range of numbers is 1....n and the size of numbers is k(small no.) then the time complexity will be theta n log..

Write a program to find the area of circle in c?

PROGRAM TO FIND AREA & PERIMETER OF CIRCLE IN C++

#include

#include

void main()

{

clrscr();

double rad, area, perimeter;

cout<<"enter the radius ";

cin>>rad;

area=3.14*rad*rad;

perimeter=2*3.14*rad;

cout<<"\n the area is "<

cout<<"\n the primeter is "<

getch();

}

WRITTEN BY- AYUSH PRANJAL

ayush-pranjal@in.com

Is it true or false while loop repeats infinitely when there is no statement inside the loop body that makes the test condition false?

That statement is definitely TRUE. This is the major concern with using while loops and why you need to be very careful using them. A false statement inside the loop would cause its immediate termination. That is desired in all cases.

Write a function that takes an integer value and returns the number with its digits reversed?

// reversed.cpp

#include

using std::cout;

using std::cin;

using std::endl;

using std::ios;

#include

using namespace std;

int reversByValue(int);

int main()

{

int num;

cout << "Enter a number (0 for End): "

cin >> num;

while (num != 0) {

cout << "The number with its digits reversed is: "

<< reversByValue(num) << endl;

cout << "\nEnter a number (0 for End): ";

cin >> num;

}

cin.ignore();

return 0;

}

int reversByValue(int numRev)

{

int resultNum = 0;

while (numRev != 0)

{

resultNum = (resultNum * 10) + (numRev - (numRev / 10) * 10);

numRev = numRev / 10;

}

return resultNum;

}

Why you use for loop inside switch statement?

Because you have to repeat something. (Or you can use while-loop, too.)

How do you solve fatal error in c program?

Fatal errors are errors or exceptions that cause a program to abort. You solve fatal errors by examining the source code to determine what is causing the error. If the error is an exception, it can be caught. That is precisely why we always place a catch-all exception handler in the main function. Once we know where the exception was raised we can write code to specifically deal with that exception -- at or near the point it was actually raised.

However, not all fatal errors throw exceptions. For example, a divide by zero operation is a fatal error because your program has allowed the system to attempt an illegal operation for which there is no reasonable means of recovery. The only solution is to avoid invoking illegal operations; test your assumptions and always assert that all operands are within the acceptable range of the operator.

Fatal errors can also be caused by hardware failure, such as bad RAM, which is beyond the remit of applications programmers.

Write a shell program in unix to find palindrome of the number?

echo "Enter number:"

read num

r=0

d=0

a=$num

while [ $num -gt 10 ]

do

d=`echo $num % 10 |bc`

r=`echo $r \* 10 + $d |bc`

num=`echo $num / 10 |bc`

done

d=`echo $num % 10 |bc`

r=`echo $r \* 10 + $d |bc`

if [ $a -eq $r ]

then

echo "given number is polindrome"

else

echo "given number is not polindrome"

fi

How to compare two array list when one array list always fluctuate rows?

I am creating one array list and attempting to equals to another array list, the reader through CSV file. CSV row is not in the same order, changing everything when downloading. I tried with equals and compare to but both fail due to row fluctuations. How do I compare? Apart from row number, everything is the same .

For more Information Subscribe to our page - softwaretestingboard