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();
}
What is max no of hops in hypercube network to go from one node to another?
This depends on if you are using hubs or switches.
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
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
Means to put a new item in the proper place in a sorted list.
Write a c program that use both recursive and non-recursive functions?
#include<stdio.h>
int n fact (int n);
int r fact (int n);
main()
{
int n,x,y;
printf("enter the number");
scanf("%d",&n);
x=nfact(int n);
printf("n fact result=%d",x);
getch();
}
int n fact(int n)
{
int i,f=1;
if(n==0::n==1)
return(1);
else
for(i=1;i<=n;i++)
f=f*i;
return(f);
}
int r fact(int n);
{
if(n==0)
return(1);
else
return(n*r fact(n-1));
}
Distance vector routing in c program?
#include<stdio.h>
int main()
{
int n,i,j,k,a[10][10];
printf("\nEnter the number of nodes: ");
scanf("%d",&n);
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
printf("\nEnter the distance between the host %d%d:", i+1,j+1);
scanf("%d",&a[i][j]);
}
}
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
printf("%d\t",a[i][j]);
printf("\n");
}
for(k=0; k<n; k++)
{
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(a[i][j]>a[i][k]+a[k][j])
a[i][j]=a[i][k]+a[k][j];
}
}
}
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
b[i][j]=a[i][j];
if(i==j)
b[i][j]=0;
}
}
printf("\nThe output matrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
printf("\n");
}
return 0;
}