Pre increment and post increment?
Both increment the value of the variable by one. The difference is the value of the increments expression itself. With preincrement value is taken after incrementing, and with postincrement value is taken before incrementing.
Example:
Let x have value 5.
y = ++x;
Both y and x are assigned value 6.
Again let x have value 5.
y = x++;
y is assigned value 5. x is assigned value 6.
extern "C"
{
int printf(const char *format,..);
}
int main()
{
printf("Hello world");
}
coz all the include statement does is copy the requested file at the asked location.
What is difference between stack pointer and program counter?
Both of them are pointers, but otherwise they are completely unrelated. The former points to the current position of the stack, the latter points to the current instruction of the program.
import java.util.Scanner;
public class NumberSystem
{
public void displayConversion()
{
Scanner input = new Scanner(System.in);
System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal",
"Binary", "Octal", "Hexadecimal");
for ( int i = 1; i <= 256; i++ )
{
String binary = Integer.toBinaryString(i);
String octal = Integer.toOctalString(i);
String hexadecimal = Integer.toHexString(i);
System.out.format("%-20d%-20s%-20s%-20s\n", i,
binary, octal, hexadecimal);
}
}
// returns a string representation of the decimal number in binary
public String toBinaryString( int dec )
{
String binary = " ";
while (dec >= 1 )
{
int value = dec % 2;
binary = value + binary;
dec /= 2;
}
return binary;
}
//returns a string representation of the number in octal
public String toOctalString( int dec )
{
String octal = " ";
while ( dec >= 1 )
{
int value = dec % 8;
octal = value + octal;
dec /= 8;
}
return octal;
}
public String toHexString( int dec )
{
String hexadecimal = " ";
while ( dec >= 1 )
{
int value = dec % 16;
switch (value)
{
case 10:
hexadecimal = "A" + hexadecimal;
break;
case 11:
hexadecimal = "B" + hexadecimal;
break;
case 12:
hexadecimal = "C" + hexadecimal;
break;
case 13:
hexadecimal = "D" + hexadecimal;
break;
case 14:
hexadecimal = "E" + hexadecimal;
break;
case 15:
hexadecimal = "F" + hexadecimal;
break;
default:
hexadecimal = value + hexadecimal;
break;
}
dec /= 16;
}
return hexadecimal;
}
public static void main( String args[])
{
NumberSystem apps = new NumberSystem();
apps.displayConversion();
}
}
What is overloading function in c and explain with example?
Short answer: You can't.
Long answer: Function overloading is when you define two functions with the same name that take different arguments, e.g.:
void pickNose(int fingerId);
void pickNose(Finger finger);
This is a valid construct in C++, which supports function overloading. If you try this in C, you'll get some error about function already defined.
What do you mean by a low level language?
A low-level programming language is one that has little to no abstraction between the source code and the machine code produced by the language translator. Machine code has no abstraction whatsoever and is the lowest possible level of coding (machine code is the native language of the machine). Assembly language has very little abstraction because each mnemonic either maps 1:1 with a specific machine operation code (opcode), or maps to one of several opcodes that only differ by the operand types and can be implied from those operands.
Given the lack of abstraction, low-level code is machine-dependent code and is therefore non-portable. That is, code is written specifically to suit the assembler and thus the machine it was intended to execute upon. Conversely, high-level code has a high-level of abstraction and is generally portable. That is, code is written to suit the language compiler or interpreter rather than underlying hardware. High-level languages generally provide a much more convenient method of producing low-level code that is much easier for humans to read, write and maintain, largely due to the high-level of abstraction these languages provide.
Yes and no. It really depends on what the programmer decides. A GUI interface is usually composed of many objects, some of which may be part of the operating system's development kit (common controls), some of which may be user-defined and others which may be defined by a third-party. However, all objects respond to messages whenever a mouse cursor enters or leaves an object, or otherwise interacts with the object (moves or clicks upon the object). A programmer can intercept these messages and decide how the cursor should change, if at all.
How do you access and store the elements of array?
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a[10],i;//array declaration
clrscr();
printf("\n enter the elements of array");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\n the elements you enter into the array");
for(i=0;i<10;i++)
printf("%5d",a[i]);
getch();
return 0;
}
How procedural oriented programming language is interdependency?
Function which uses other function as part of it programming is known as function interdependent
How do you handle object array?
Exactly as you would any other type of array. An object's size is determined in the same way a structure's size is determined, by the sum total size of its member variables, plus any padding incurred by alignment.
However, you cannot create arrays of base classes. Arrays of objects can only be created when the class of object is final; a class that has a private default constructor, otherwise known as a "leaf" class. This is because derived classes can vary in size; array elements must all be the same size.
To create an array of base classes you must create an array of pointers to those base classes instead. Pointers are always the same size (4 bytes on a 32-bit system).
Static arrays are ideally suited to arrays of leaf objects where the number of objects never changes, or the maximum number of objects is finite and fixed. Although you can use dynamic arrays of leaf objects, you will incur a performance penalty every time the array needs to be resized, because every object's copy constructor must be called during the reallocation. Dynamic arrays are better suited to arrays of pointers to objects -- only the pointers need to be copied during resizing, not the objects they point to.
Write a program in c to draw a star and rotate it?
// asterisk pyramid
#include<iostream>
using namespace std;
int main()
{
int count = 0;
for (int width = 0; width <= 10; width++)
{
for (int alignLeft = width; alignLeft <= 15; alignLeft++)
{
cout << " ";
}
for (int space = 1; space < count; space++)
{
cout << "*";
}
cout << endl;
count += 2;
}
return 0;
}
What is do while loop in VB 6?
Structure:
do (while(expression) or until(expression))
.
.
.
loop (while(expression) or until(expression))
This is called a loop in VB and it is used to do something more than one times.
It may be used without any of the parameters "while" or "until" but in such case you have to make your code exit of the loop or most likely your program is going to stop responding.
The while parameter is used when we want the code in the loop to be executed WHILE the expression is True.
Example:
variable = variable + 1
The until parameter is used when we want the code in the loop to be executed until the expression gets True.
Example:
variable = variable + 1
How do you make chess game in c plus plus programming?
This question cannot be answered here. Go to amazon.com and find a book about chess-programming.
What is difference between c and oops?
C is a programming language, oops is what you say when you realize you were wrong in something. Note: Some programming languages are known as object-orient languages, C is not one of them, but some derivatives of it (C++, C#, Java) are.
Many researches show that relationship between watching violence on TV and violent behavioral patterns is positively correlated. Can we statistically say from this information that viewing violence on television causes children to behave in a violent way?
Explai the nature of the various types queues in data structures?
The queue is a linear data structure where operations of insertion and deletion are performed at separate ends also known as front and rear. Queue is a FIFO structure that is first in first out. A circular queue is similar to the normal queue with the difference that queue is circular queue ; that is pointer rear can point to beginning of the queue when it reaches at the end of the queue. Advantage of this type of queue is that empty location let due to deletion of elements using front pointer can again be filled using rear pointer. A priority queue is a queue in which each element is inserted or deleted on the basis of their priority. A higher priority element is added first before any lower priority element. If in case priority of two element is same then they are added to the queue on FCFS basis (first come first serve). Mainly there are two kinds of priority queue: 1) Static priority queue 2) Dynamic priority queue A double ended queue (or deque ) is a queue where insertion and deletion can be performed at both end that is front pointer can be used for insertion (apart from its usual operation i.e. deletion) and rear pointer can be used for deletion (apart from its usual operation i.e. insertion)
Why are operating systems written in the C language?
Speed, power, efficiency, well supported libraries, generally. Almost everything (But not absolutely everything.) has at least C bindings one can use.
Not to mention you're guaranteed to have the standard C library to handle a great deal of the core functionality of the program.
What is physical data structure and logical data structure?
Physical data structure: This is the physical equipment involved in the network eg router, cabling etc).
Logical data structure: This is how the information flows internally and externally (the transfer of information from one node to another on the network).
What is the difference between run time and compile time in c?
Compile time errors are detected at the compilation of a program. These are usually syntactical errors. A program cannot be compiled and hence executed if it contains a compile time error.
for example,
int a b=0;
above statement will produce a compile time error as a and b must be separated by a comma(,).
Runtime errors are logical errors. They don't affect the compilation of the program but causes a program to produce unwanted output. The program becomes buggy.
for example,
sum=sum-a[i];
in above statement, no syntactical error is present and hence the program will get executed successfully. But from a logical point of view, sum was supposed to be the addition of array elements. using minus(-) instead of plus(+) will give unwanted or incorrect output.