Which operator can be used in some situations to simplify nested selection structures?
The ternary conditional operator:
x = a ? b : c;
This is the literal equivalent of the following if statement:
if (a) {
x = b;
} else {
x = c;
}
Note that a, b and c are all expressions (or compound expressions). Expression a must be a Boolean expression (evaluating true or false) while expressions b and c must be implicitly convertible to x's data type.
A real-world example:
// Return the larger of any two integers
int max (int a, int b) {
return a>b ? a : b;
}
What is maximum length of variable in c?
The maximum length of a variable is dependent on the platform. In a 32 bit platform, this might be 4 bytes, although the compiler and run-time library might support 64 bit, or 8 byte variables. In a 64 bit platform, the length might be 8 bytes.
(Arrays, strings, structures, classes, etc. are aggregated types, not scalar types, so they don't count in this answer.)
When do we make a virtual function pure?
We make a virtual function pure whenever we wish to make our class an abstract base class (an abstract data type). Unlike a virtual function, pure virtual functions must be overridden by a derived class or by one of its derivatives (the function remains pure virtual until it is overridden, at which point it becomes virtual). Derived classes that do not provide a complete implementation for all the pure virtual functions it inherits become abstract themselves. You cannot instantiate an abstract base class other than through derivation.
What are break and continue statement in c language?
Break is used to exit the closest loop. Continue will cause the program to go to the beginning of the loop.
for(int x=0;x<10;x++)
{
//continue;
for(int y=0;y<10;y++)
{
break;
}
}
The break statement causes the inner loop to stop at the first iteration. If the continue statement was uncommented, the inner loop would never be executed because the program would jump back to the beginning(until x = 10 of course).
What is worst case complexity of quick sort?
Selection sort has no end conditions built in, so it will always compare every element with every other element.
This gives it a best-, worst-, and average-case complexity of O(n2).
To find the largest element of an array in c plus plus?
int GetMaxElement( void * array)
{
if (array != 0)
{
return(max(array[], typeof(array)));
}
return(0);
}
Is c or c a procedural oriented language?
One definition of a "procedural programming language" is a language that is used to describe how a program should accomplish the task it is to perform. This is in opposition to a "declarative programming language" that is used to describe what the program should accomplish rather than how it accomplishes the task.
What is a definition of data types?
A data type is, well, the type of data. The most common types are strings (text with spaces, punctuation, etc), integers (whole numbers within a certain range, depending on the specific type), and decimal numbers (1.7). Depending on the database software, there will be many other types.
Write a c program to accept 3 digits and print all possible combinations from these digits?
Everyone i am ajay Verma and i answer this question, Write this programe in note pad:-
using System;
class MyClass
{
public static void Main(string [] args)
{
int n,d,result=1,sum=0;
Console.WriteLine("Enter any Number");
n=Convert.ToInt32(Console.ReadLine());
for(;n>0;)
{
d=n%10;
Console.WriteLine(d);
n=n/10;
}
}
}
How do you explain characteristics of algorithm?
Characteristics of algorithms are:
Finiteness: terminates after a finite number of steps
Definiteness: rigorously and unambiguously specified
Input: valid inputs are clearly specified
Output: can be proved to produce the correct output given a valid input
Effectiveness: steps are sufficiently simple and basic.
What does compiler mean in programming?
A compiler is a program that converts the language into machine code, also known as binary (1s and 0s). Not all programming languages need compilers. Some are assembly and still others can just be straight and utter machine code.
The maximum number of elements will depend on the type of array and the available memory. An array of char requires only 1 byte per element but an array of pointers requires 4 bytes per element (8 bytes on 64-bit systems). Arrays of objects or structures would likely require more memory per element.
For all practical purposes, the maximum size is 2,147,483,647 elements, which is the maximum positive range for a 4-byte integer (0x7FFFFFFF). At 1 byte per element, that works out at 2GB.
Distinct threadlike structures containing genetic information are called?
They may be called several things. They could be called Chromosomes (however these are when the genetic information has been aggregated into bodies (usually resembling an X). It can be called DNA (meaning deoxyribonucleic acid) which is the long strand of information made of up base pairs which resembles a twisted ladder. A small segment of that ladder which produces only one protein may be called a Gene. (from whence we get the term genetics).
When DNA is being used to make pieces of the cell and produce stuff in genera, it is transcoded into RNA (Ribonucleic Acid) which is a temporary form of the genetic information which can be taken from the nucleus of the cell where the DNA is stored and turned into protein elsewhere. This form of RNA is known as Messenger (m)RNA.
containing genetic information: Chromatin condenses to form chromosomes. These distinct, threadlike structures contain the genetic information or DNA.
How can you change the value of a constant variable in C?
You can change a static variable by putting the static variable into a function that has operations that you intend to execute upon the variable. Example, you want to change the static variable to another value or make an addition of 2. Put the source code inside a function with the static variable declared locally within the function.
Every time you call the function, the static variable value will change. Take note that the static variable retains the last value you declared it in your function call.
A more terse answerLocal variables declared as static are changed as normal; they are special in that their values persist across function calls.How can you write a c program that prints a table of trigonometric values for sin cos and tan?
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
const float pi=3.14;
float angle,radian;
clrscr();
printf("Angle\t Radian\t\t sin\t\t cos\t\t tangent");
for(angle=0;angle<=180;angle+=10)
{
radian=(pi/180.0)*angle;
printf("\n%0.0f\t%f\t%f\t%f\t%f",angle,radian,sin(radian),cos(radian),tan(radian));
}
getch();
}
Write c program to check the password?
What programming language is use to create a website?
At the most basic level is HTML and CSS. CSS is used mostly for the layout and visual design of the website. Usually combined with those is JavaScript. However, more and more websites are using PHP and MySQL. These are becoming more popular and if you ever want to have a website with multiple user accounts that your visitors can log into, PHP is probably the way to go. Might as well start out with it, then add this ability later when you're ready for it.
Write a program on Trace of matrix in C?
#include <conio.h>
#include <stdio.h>
void main()
{
int a[16][16];
int c=1,i,j,k,m=0,n,x;
clrscr();
printf("Enter the number of rows and columns for the square matrix \n");
scanf("%d",&n);
x=n;
while(n>=1)
{
for(k=0;k<n;k++)
a[m][k+m]=c++;
for(k=1;k<n;k++)
a[k+m][n-1+m]=c++;
for(k=n-2;k>=0;k--)
a[n-1+m][k+m]=c++;
for(k=n-2;k>0;k--)
a[k+m][m]=c++;
n=n-2;
m=m+1;
}
for(i=0;i<x;i++)
{
for(j=0;j<x;j++)
{
printf("%5d",a[i][j]);
}
printf("\n");
}
getch();
}
Write a program to find greatest of three number using conditional operator in c?
To find greatest of 3 digits in one line
#includ<stdio.h> #include<conio.h>
void main() { int a,b,c; printf("enter a,b,c:); scanf("d%d%d",&a,&b,&c);
printf("greatest no: %d"(a>b)?((a>c)?a:c):((c>b)?c:b));
printf("have a nice day");
getch();
}
What is the difference between C and HTML?
HTML is a widely accepted web-design language. With HTML, you surround a block of text with “tags” that indicate how the text should appear or what purpose it has in a document. Cascading Style Sheets (CSS) make it faster and easier to create and maintain websites. CSS works with HTML (or any markup language) to apply a uniform style and format to your website. CSS allows you to set your site’s fonts, colors, layouts and more without repeating the HTML formatting tags throughout. SSL
What are the advantages of a pointer variable?
Arrays takes consecutive memory space.
So, if you have 5 consecutive memory blocks free which is consecutive, an error will
occur while creating an array which takes more than 5 blocks of memory.
But if you use pointer, then it don't need consecutive memory blocks all the elements can be placed anywhere in memory.
Built-in functions in turbo c?
i want a coding of a program of a calculator using graphics in c language??
What high level programming languages are translated by a compiler?
Almost any language can be used to develop a compiler. The first compilers were written in assembly language or machine code but today they are typically written in C or (more commonly) C++. Other languages can be used, however the key aspects of any compiler are speed and efficiency, in which both C and C++ excel.
How does an inline function differ from a preprocessor macro in c?
In order to get the best of both worlds, C++ introduced the inline keyword. By specifying that a function is inline, the compiler will take the function you have written and basically replace the function call that would have been generated with the function itself. In other words, using an inline function is pretty much directly putting your code there, except it's prettier and more maintainable.
Overuse of inlining function will cause bloated code for a very marginal increase in speed, if any. Inline functions are best suited for small quick functions. Also note that the inline keyword is a request to inline a function and the compiler may not necessarily honor that request. One example would be attempting to inline a recursive function.
In other languages like Java and C#, you are not able to specify what is inlined and what is not. The compiler will automatically make that decision without any input from the programmer.
What is the use of break and exit statements in c?
A break is a jump statement that allows code to exit a statement block without processing the remaining instructions in that statement block. Execution continues with the statement following the statement block.
Jump statements (the break, return, continue and goto keywords) are typically used in conjunction with a conditional expression, to allow execution to branch to another section of code within the same function whenever the expression is true. Function calls do a similar type of thing, branching off to other sections of code, but execution always returns to the point the call was made. Jump statements do not.
However, jump statements are also used in conjunction with switch statements. If a case label does not have a jump statement before the next case label is encountered, execution will fall through to the next label (just as as if that label did not exist). Sometimes this may be the intention but, in most cases, once a specific case has been handled, execution is normally passed to the statement immediately following the switch block, in which case a break is required (return and goto can also be used to exit a case label, but not continue). The final case (or default case) does not require a break if execution is expected to fall through to the statement following the switch statement.
With regards to the other jump statements:
The continue statement is used in loops, to start a new loop without executing any remaining command in the loop. In do..while() loops, execution is passed to the while(condition) expression.
The goto statement jumps to a given label, which must be present somewhere within the same function. A label is a user-defined name followed by a colon, marking the point in the function the goto will jump to.
The return statement exits a function altogether, returning control back to the calling function.