How do you use the conditional statement of turbo c?
#include<stdio.h>
void main()
{
int a=10,b=15;
clrscr();
if(a>b)
printf("%d is the large number",a);
else
printf("%d is the large number",b);
getch();
}
How can you reduce no of passes in compiler?
In order to reduce the number of passes in a compiler, all symbols have to be fully declared and defined before they are referenced. That's assuming, of course, that you would want to write a single pass compiler to start with. Most current compilers are very good at what they do, and reinventing the wheel, other than for a computer science class, is meaningless.
Is stack a linear data structure?
Yes. All object on a stack must be of the same type. However, the type may be a base class in which case all objects on the stack must either be of that type or be derived from that type. That is, if a circle, triangle and rectangle class are all derived from a common shape class, a stack of shapes would allow instances of all four types because they are all a type of shape.
Why is it important to allocate the correct type of data?
It is important to use the correct data type so you dont get confused and makes it easier for the system to Calculate numbers, and when text is text. For example Windows Excel wouldnt be able to calculate the data if it wasnt for using the correct data type
A full binary tree with n non leaf nodes contains how many nodes?
2n-1 nodes2n+1 is the right answer
nonleaf leaf
1 2
2 3
3 4
4 5
5 6
6 7
7 8
Different types of pointers in c language?
... are usable.
void pointer (generic pointer) : a special type of pointer which point to some data
of no specific types.
void *p;
null pointer : a special type of pointer which point nowhere.
it is usually used to check if a pointer is pointing to a null or free
the pointer during deallocation of memory in dynamic memory allocation;
it is define by using the predefine constant NULL
int *p=NULL;
wild pointer : uninitialized pointer. it hold a garbage value. i.e it is not pointing to
any memory location yet.
dangling pointer: pointer pointing to a destroyed variable.
it usually happen during dynamic memory allocation when the
object is destroyed but not free and the pointer is still pointing
to the destroy object.
What is the hexadecimal of black?
The hexadecimal of black, assuming that "black" is an ASCII character string is 0x626c61636b.
If you mean RGB, it is R=00H, G=00H, B=00H, or 000000H combined.
How do you convert a program in turbo c into gcc c?
Code written against Borland compilers is non-portable. You will either have to make the implementation-specific libraries from Borland available to gcc or change the code to eliminate the implementation-specific code.
What is the difference between a data type and a data structure?
Data type can be regarded as data structure because we can define our own data type by using typed function. Data types are the category in which the variable are listed to hold the specific value and data structures are the way in which the values and variables are stored in the memory. The use of a data type called structures allows a collection of values possibly of different types to be treated as a single item. Each data structure is built up from the basic data types of the underlying programming language using the available data structuring facilities, such as
arrays & pointers
Program to copy one file into another using command line arguments?
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
int copy_file (const std::string& src_name, const std::string& dst_name)
{
// Ensure source exists for input.
if (!std::ifstream (src_name).good())
{
std::cerr << "The system cannot find the file specified.\n" << std::endl;
return -1;
}
// If destination exists (for input), ask to overwrite.
if (std::ifstream (dst_name).good())
{
std::string yn;
while (!yn.size())
{
std::cerr << "The destination file exists. Overwrite? [Y/N]";
std::getline (std::cin, yn);
if (yn.size())
{
switch (yn[0])
{
case ('Y'): case ('y'): continue;
case ('N'): case ('n'): return -1;
default: yn.clear();
}
}
}
}
// Try opening or creating the destination.
std::ofstream dst (dst_name, std::ios_base::binary);
if (!dst.good())
{
std::cerr << "The destination file could not be created or opened for writing.\n" << std::endl;
return -1;
}
// Definitely good to go.
std::ifstream src (src_name, std::ios_base::binary);
std::cout << "Copying " << src_name << " to " << dst_name << std::endl;
dst << src.rdbuf();
std::cout << "\t1 file copied.\n" << std::endl;
return 0;
// Note: both files close when they fall from scope...
}
int main (int argc, char* argv[])
{
switch (argc)
{
case (3):
return copy_file (argv[1], argv[2]);
case (2):
if (std::string(argv[1])!="/?")
break;
// strip the path and extension from the command
std::string command (argv[0]);
size_t last_backslash = command.rfind ('\\') + 1;
size_t last_period = command.rfind ('.');
std::string exe = command.substr (last_backslash, last_period-last_backslash);
std::transform (exe.begin(), exe.end(), exe.begin(), ::toupper);
std::cerr << "Copies a file to another location.\n\n"
<< exe << " source destination\n\n"
"source\t\tSpecifies the file to be copied.\n"
"destination\tSpecifies the filename for the new file.\n" << std::endl;
return 0;
}
std::cerr << "The syntax of the command is incorrect.\n" << std::endl;
return -1;
}
What are the Application of merge sort in real life?
It is used in tape drives to sort data - its good with parallel processing, which is why it is used there.
What is the algorithm for a for loop?
the for loop is basically a repitation or traversing loop means one's to write his name 100 times he use the for loop
example
for(i=0;i<=100;i++)
{
printf("my name is AA");
}
the for loop checks the condition until i<=100 repeates the name or check the condition upto 100 times and then terminates.
Sort the array of integers in Descending order?
Make use of Java's robust library:
// filled with various ints
int[] a;
// temporary variable for swapping values
int temp;
// sort with fast, built-in algorithm
java.util.Arrays.sort(a);
// reverse the array
for( int i = 0; i < a.length/2; ++i ) {
temp = a[i];
a[i] = a[a.length - i - 1];
a[a.length - i - 1] = temp;
}
Obviously, if you're concerned with execution speed you could write your own sort method which would sort into descending order instead of ascending order (perhaps by modifying Java's sort algorithm).
What are c in and c out in c plus plus?
C and C++ are two common languages used for writing programs and getting suitable desired outputs. They are both strongly typed and, like most other languages in widespread use, imperative.
C is a raw procedural language developed in 1969 to operate on UNIX systems; see the related link for an extensive history. It makes use of structures (simple groups of named values), functions, pre-processor macros, and pointers to memory addresses. It includes some built-in functions known as its standard library. The language, along with its libraries, was originally standardized in 1989 and again in 1999.
C++, begun in 1979 and standardized in 1998, is a step above C and intended to improve the language with object-oriented features such as classes, inheritance, polymorphism, etc. It is a super set of C, meaning that most C source is perfectly valid as C++. It is easier than C because of its extra features, but it is also much more complex and learning all its features is a major accomplishment. More Windows applications are written in C++ than C, but if either one provides a DLL file the other can talk to the first.
What are programming languages written in?
which programs?the easiest way to find out is to go to wikipedia and search for particular program and on right hand side you will see information in which programming language is written
Major difference of turbo c and ansi c and its structures?
Turbo C is an earlier C compiler from Borland. ANSI C is the standard for the C programming language. Therefore, the two are different by definition - Turbo C is a computer program, and ANSI C is a specification for a computer program, which can be implemented in various ways. If we rephrase the question as "what are the difference between the C versions as depicted in the ANSI standard and as implemented in Turbo C?" I would say that most are PC-specific such as the use of far pointers.
However you want!
Pseudo code is not a well defined programming language. The idea is to write something that looks like code, but doesn't necessarily have to run in any specific language.
For example, you could write:
for all values in some_array:
if value is empty:
fill value
without defining at this point what exactly it means for a value to be empty, or how to fill a value.
Write a program to input the square matrix and display the sum of diagonal elements?
#include<iostream>
#include<random>
#include<time.h>
int main()
{
std::default_random_engine generator ((unsigned)time(0));
std::uniform_int_distribution<int> distribution (1,9);
std::cout << "Array:\n" << std::endl;
int a[3][3];
for (size_t r=0; r!=3; ++r)
{
for (size_t c=0; c!=3; ++c)
{
a[r][c] = distribution (generator);
std::cout << a[r][c] << '\t';
}
std::cout << std::endl;
}
std::cout << std::endl;
int diagonal=0, anti_diagonal=0;
for (size_t i=0; i!=3; ++i)
{
diagonal += a[i][i];
anti_diagonal += a[2-i][i];
}
std::cout << "Diagonal sum : " << diagonal << std::endl;
std::cout << "Anti-diagonal sum : " << anti_diagonal << std::endl;
}
Basically it's a list.
Instead of typing x0, x1, x2, x3, x4... x99, an array lets you just type x[100]. Then to use each variable you just type x[number] and use it as normal. Arrays are so useful because you can iterate, or repeat, over them easily. You could define an array, then define an integer i. They you could make a loop in your program that increases each x value by 2. Just make it so I gets bigger each run of the loop and type this:
x[i] = x[i] + 2
A Note: if you define the array x to have 100 values, than it will go from 0 to 99, not 1 to 100.
There are also more advanced arrays that can get bigger as you need them to. They will grow without you thinking about it. You can also add data in the middle, and have all the data after it shifted one place. Or you could delete a piece of data from the middle and have all data after it shifted back one place. These arrays are generally called mutable (which means changeable) arrays. Normal arrays are called immutable arrays.
How do you find the sum of series 1 plus 2 plus 3 plus n using a c program?
#include<iostream.h>
#include<conio.h>
void main()
{
int num_last,res=0;
cout<<"Enter the last number : ";
cin>>num_last;
for(int i=0;i<=num_last;i++)
res=res+i;
cout<<"Result is "<<res<<endl;
getch();
}
Which is the unary operator used to dereference a pointer and return the value stored in it?
The asterisk (*) operator dereferences a pointer and returns the value stored in the memory pointed to by the pointer.
It is much easier to discover errors in a program that is well analyzed and well designed. Furthermore, a thoroughly analyzed and carefully designed program is much easier to follow and modify.Even the most experienced programmers spend a considerable amount of time analyzing a problem and designing an algorithm
Which language is processor to c programming language?
That depends on each individual compiler. Some are written in assembly, some in C/C++, others are written in whatever high-level language the author likes best.