List of command used in c language?
It's easy: there are no commands in C, but a few statements (such as: expression, if, else, switch, while, do-while, for, break, continue, return and goto), and countless library functions (like printf, malloc and fopen).
What do you mean by c taken programming in c?
A C program is a computer program written using the C programming language.
Write your own c plus plus functions for the following problem Print the sort output on the console?
#include<iostream>
#include<vector>#include<string>
int main()
{
std::vector<std::string> names;
for (int loop=0; loop!=10;)
{
std::cout << ++loop << " enter a name: ";
std::string name;
std::cin >> name;
names.push_back (name);
}
names.sort();
std::cout << "Sorted names:" << std::endl;
for (auto name : names)
std::cout << name << std::endl;
}
What are the steps involved in system approach to solve the problems?
If this is Mathematical, or Physics, Chemistry numericals you are talking about then, 1---> Read the problem. 2---> Identify the question or what has to be found out. 3---> Read the data given in the problem and analyze it. 4---> See if you know any formula/concept that can help you use the data given in the problem. 5---> Apply, solve carefully. Obtain result.
Time and space complexities of various sorting methods?
Bubble sort-O(n*n)-in all cases
Insertion sort-O(n*n)-in avg and worst case in best case it is O(logn)
Quick Sort-0(nlogn)-in avg n best case and 0(n*n)-in Worst case
selection sort-same as bubble
Linear search-o(n)
Binary Search-o(nlog)
Any doubt mail me-jain88visionary@rediffmail.com
How do you Calculate the average of two numbers then return the average in c plus plus?
Use the following function:
/* returns the average of two real numbers */
double average (const double a, const double b) {
return a/2.0 + b/2.0;
}
Note that we do not use (a+b) / 2.0 because the expression a+b could overflow the range of a double. By dividing each value by 2 before summing we ensure the result can never overflow no matter how large a and b are.
Ideally, you should write separate functions to cater for float and long double arguments independently:
/* returns the average of two long doubles */
long double average_lng (const long double a, const long double b) { return a/2.0 + b/2.0;
}
/* returns the average of two floats */
float average_flt (const float a, const float b) {
return a/2.0F + b/2.0F;
}
For mixed-mode arithmetic, always use the highest precision argument. E.g., the average of a float and a double is a double, so use the function that returns a double, not a float. The float argument will be implicitly cast to a double.
What is difference between multi character constant and string literals?
In C, you can assign integers multiple characters such that they fit in their size. For e.g.:
int - 4 bytes
char - 1 byte
So an assignment like this is valid:
int a = 'ABCD';
The first byte in a will be assigned the value of 'A', the second - 'B' and so on.
A string literal is a character array constant. It is enclosed in double quotes and assignment can only be made to a char pointer. There is no limit on the size of the literal and it is terminated with a null character. e.g.:
char str[] = "This is a trial";
What are the names of computer programming courses?
Answer-
There are various levels of computer programming courses conducted by computer schools. As per your career goals you can do diploma, associate, bachelor or master degree courses in computer programming.
How many data types can the elements of an array have?
Depends on your language. Assuming java: If you make it an Object[] then it can contain any object
For primitive types you must either make a primitive type array, ie double[], char[] which can contain only those primitives, or creater an Object[] and use primitive wrapper objects ie java.lang.Integer etc.
How is an array name interpretedwhen it is passed to a function?
An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.
What is the base address of an array in c program?
the address of variable (pointer) that contains array
It's -1, but in theory could be something else on some exotic platforms, but still negative. See the related links below for further information.
Difference between C and C plus plus languages?
C was the C++ predecessor. As it's name implies, alot of C remains in C++. Although not actually being more powerful than C, C++ allows the programmer to more easily manage and operate with Objects, using an OOP (Object Oriented Programming) concept.
C++ allows the programmer to create classes, which are somewhat similar to C structures. However, to a class can be assigned methods, functions associated to it, of various prototypes, which can access and operate within the class, somewhat like C functions often operate on a supplied handler pointer.
Although it is possible to implement anything which C++ could implement in C, C++ aids to standarize a way in which objects are created and managed, whereas the C programmer who implements the same system has alot of liberty on how to actually implement the internals, and style among programmers will vary alot on the design choices made.
In C, some will prefer the handler-type, where a main function initializes a handler, and that handler can be supplied to other functions of the library as an object to operate on/through. Others will even want to have that handler link all the related function pointers within it which then must be called using a convention closer to C++.
To finish this discussion, C++ applications are generally slower at runtime, and are much slower to compile than C programs. The low-level infrastructure for C++ binary execution is also larger. For these reasons C is always commonly used even if C++ has alot of popularity, and will probably continue to be used in projects where size and speed are primary concerns, and portable code still required (assembly would be unsuitable then).
What is null pointer assignment?
This error message means that somewhere in your program you have used a pointer-varible containing NULL-value. (Within an actual OS it with stop the program immediately, but in MS-DOS it doesn't.)
How compilation and linking and loading related in c?
Compilation is the act of translating high-level programming language code into low-level native machine code. Computers cannot execute high-level programming language code, it must be converted to native machine code first. In C, this is achieved using a compiler that is specific to the machine. However, the compiler only produces object code files. In order to produce a machine code executable, the object files must be linked along with any required library code. This is achieved by another machine-specific program called the linker.
Why else if ladder bettar than switch?
The if/else ladder construction is not better than a switch. However, in some cases one is preferred. Switches for instance usually execute faster since the compiler can optimize such constructions better. This is because the compiler doesn't have to take into account any programmer forced orders of execution.
The if/else ladder is preferred where the conditions to be checked are not fixed.
So, it all depends on the situation.
Why arrays are not primitive data type?
An array is a primitive data type. It is the element type that may or may not be primitive.
What are escape sequences in c language?
Escape sequences are combination of characters which when used together form one single unit with a special meaning.Eg:
when a blackslash('\') and 'n' are written together like '\n', this represents a newline character.
For more escape sequences visit the related link.
What is meant by the data type of a variable in c plus plus?
The built-in (fundamental) data types are int, char, bool, float, double and pointer. All other integral types are either modified types or aliases (typedefs). User-defined types (including those provided by the standard library) are not considered part of the language.
Are low level computer languages portable?
low level language is not portable because using these language we are not run programs where we not create those programs or we r not able to run those programs to another machine.....
What is an inheritance Explain different types of inheritance in c?
C is not an object oriented language and therefore has no native support for inheritance.
What is meant by a function returning a value in c?
Consider this example:
#include
int add(int x, int y)
{ int n=x+y;
return n; }
int main()
{ Using namespace std;
cin >> x;
cin >> y;
cout << add(x,y);
return 0; }
What happens is the main() function asks the user for 2 integers then sends them to add() in the cout statement. Add() adds the two integers and returns the sum to the function that called it (main()) so technically 'add(x,y)' in the cout statement is replaced with add()'s return value. So if the user said x=1 and y=2, the program would print 3. NOTE:
For example, return 0 in main(). Anything else is an error code that is RETURNED TO THE OS or SHELL.
In the of Unix/Linux, we can see the returned value of main using
echo $?
In the case of Windows, we can see the returned value of main using
echo %ERROR_LEVEL%
while we are in DOS or Command prompt
A semantic error is a logic error. That is, the code may compile and run, but does not perform as you intended.
Some semantic errors can be picked up by the compiler, often shown as warning, such as:
if (x = 5) // warning: did you mean x == 5?
Others are simply impossible for the compiler to spot:
int x, y, z;
// ...
++z; // add 1 to x
In the above code, we meant to increment x, but incremented z instead. The compiler won't notice the error so this will inevitably lead to a runtime error.