What is the while loop in C programming?
"while" is an entry controlled loop statement i.e the condition is evaluated first and if it is true the body of the loop is evaluated.This process is repeated until the test condition is false;then the control is transfered out of the loop.
The general form of while is as following
syntax:
while (<condition>)
{
<statements>;
}
Disadvantages of macros in c language?
Actually macro and function are used for diff purposes.A macro replaces its expression code phisically in the code at the time of preprocessing.But in case of function the control goes to the function while executing the code.
So when the code is small then it is better to use macro.But when code is large then function should be used.
If you could get any help from the answer then plz increase my trust point.
Which data structure is used in relational model?
The correct term is "What are data structures in database management systems?"
Please learn how to speak English
~Sincerely
The Hacker
What is a value that is passed into a method when it is called?
Here is an example program that passes a Scanner object:
import java.util.*;
public class Conversion
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
doSomething(in);
}
public static void doSomething(Scanner in)
{
int q = in.nextInt();
System.out.println("The value you entered is: " + q);
}
}
Formula to convert binary to decimal and decimal to binary?
I do not know a specific formula to do it. but its very simple. really really simple
lets get a binary code = 10011101
now, we are going to convert this to decimal. You should start it from the last binary number in the given code,(right hand corner)
then multiply that number from 2 to the power of 0( 2^0)
1* (2^0) = 1* 1 = 1 --------- (A)
then we go to the next binary number. (which is 0 in this case)
now we must multiply this from 2 to the power 1. (2^1);
0 * (2^1) = 0* 2 = 0 --------(B)
do this sequentially till the first number. (multiplying from 2^2,2^3,...,2^7)
similarly you get,
1 * (2^2) = 4 ----(C)
1 * (2^3) = 8 ----(D)
1 * (2^4) = 16 ----(E)
0 * (2^5) = 0 ------(F)
0 * (2^6) = 0-----(G)
1 * (2^7) = 128----(H)
now, add the values you got in equation A,B,C,D,E,F,G,H
1+0+4+8+16+0+0+128 = 157; so this is the decimal number for the given binary code.
hope you got it!!
How do you find the minimum value of an array in c language?
Your best bet would probably be to iterate through the array using a for loop and compare each value to the current low and high values (which you would store in a local variable)
for example:
for each element in array
{
if current is less than lowest_value
lowest_value = current
else if current is greater than highest_value
highest_value = current
}
What is function in C plus plus programming language?
Functions are short procedures or subroutines that can be called as and when required. Unlike goto statements, which branch off to a labelled section of code never to return, functions always return back to the caller. Functions may also call other functions. Functions are typically used to reduce the amount of duplicate code, producing more consistent and error-free code and reducing maintenance whenever functions need to be modified. Functions are also used to make code more readable by replacing complex or compound statements with a simpler function call. By using easy to understand function names, code becomes self-documenting, reducing the need to include verbose comments that only serve to interrupt the flow of the code.
Although there is a performance penalty in calling functions as opposed to inline code, the compiler's optimisation routines can inline expand functions whenever there is an advantage in doing so. Typically this applies to short functions with one or two simple statements, but can also apply to functions that are seldom called.
Functions may also return a value back to the caller (a function that does not return a value simply returns void). Functions can modify their behaviour according to arguments supplied to the function. The number and type of arguments is dependant upon the function signature. The signature also differentiates between functions with the same name, thus allowing functions to be overloaded to cater for different arguments types.
If the argument types are references (or pointers), the function can modify the arguments passed to it unless the arguments are declared const. Passing by reference also allows functions to return more than one value to the caller (typically the return value itself is used to provide diagnostics, such as an error code).
If the arguments are passed by value, however, the function creates a local copy of the argument, thus preventing changes to the argument that was actually passed. If the argument being passed is an object, the object's copy constructor is called automatically. Since this can be detrimental to performance, objects should always be passed by reference unless the function actually needs to work on a copy of the object rather than the original object.
In C++, classes make use of functions, known as member methods, to provide the implementation of operations that may be applied to an object's data. Classes may also employ virtual functions that allow derived objects to provide more specialised implementations whilst retaining the existing generic code. This also helps to reduce duplicate code, but also allows objects to behave polymorphically. That is, it is not necessary for a generic class to know any of the implementation details of its derivatives. You simply call the generic method of the base class and the virtual table redirects the call to the most-specialised override of that function, if one exists. If not, the generic method is called instead. Classes can also make use of pure-virtual functions, such that the base class need not provide any generic implementation at all. These classes are abstract classes which cannot be instantiated by themselves. Instead, you are expected to derive new classes from abstract classes, and the derived classes must provide the implementation even if the base class provides a generic implementation. Only classes that provide or inherit a complete implementation of all pure-virtual methods can actually be instantiated.
Similarities between Structured programming and object oriented programming?
Both types of programming utilize algorithms when processing data. Procedural and object oriented programming will also logically compute the tasks assigned to it using different programming languages.
What is the difference between error and warning message in c?
Warnings and errors are both errors in C++, but warnings won't prevent your program from compiling, whereas errors will. Some warnings may be unavoidable in the interest of optimising performance, but so long as they do not affect the program's operations they can often be ignored. For instance, casting an unsigned char to a signed char has potential for loss of data if the unsigned char is greater than 127, and is therefore an unsafe cast. But if you can assert the cast is safe then the warning can be ignored. The alternative would be to cast to a larger type (such as casting to a signed short), but this might result in large changes to your program where a signed char is expected. As programmer, you are free to decide whether the warning really should be treated as an error, or if the warning can be safely ignored with prudent assertions instead.
Write a program to print the table of any number using two dimensional array in c program?
/* PROGRAMME TO PRINT THE TABLE OF A GIVEN NUMBER USING FUNCTION */
#include
#include
void table(int,int);
void main(void)
{
int num,i;
printf("\n Programme to print the mathematical table of a number.");
printf("\n Enter the number : ");
scanf("%d",&num);
printf("\n Upto how many multiples of the given number do you want? ");
scanf("%d",&i);
table(num,i);
getch();
}
void table(int num,int i)
{
for(int j=1;j<=i;j++)
printf("\n %5d * %5d = %5d",j,num,j*num);
}
Write Java program to display largest of 3 numbers?
//i hope its something like this you want
import java.util.*;
public class Count
{
public static void main(String args[])
{
double numbers;
Scanner scan;
int counter;
numbers=0;
scan=new Scanner(System.in);
for(counter=1; counter<=10; counter++)
{
System.out.println("Please enter numbers");
numbers=scan.nextDouble();
{
System.out.println("The number is "+numbers++);
}
}
}
}
How do you represent stack and queue by using one dimensional array?
You would not use an array for a stack or queue, you would use a singly-linked list. The problem with arrays is that they must grow and shrink as items are inserted or extracted, which requires the entire array to be copied, whereas linked-lists can grow and shrink dynamically without the need to copy any elements. The only reason to use an array to implement a list is when you require random access in constant time. Queues and stacks only require constant time access to the head or tail of the list, and a linked list can easily achieve that.
Implementing a stack as an array requires that new elements be inserted at the end of the array. If the array is full, it must be reallocated in order to make space for a new element. Extraction always occurs at the end of the array. While this releases elements for insertions, if they go unused for any length of time they are simply wasting memory. Thus the array must be reallocated occasionally to free the redundant memory, which is highly inefficient.
Implementing a queue has similar issues as all insertions are at the end of the array, however it is further complicated by the fact extractions must occur at the beginning of the array. Thus every element must be copied to its preceding element every time an element is removed from the head of the queue. This frees up the end of the array, but the need to reallocate and copy elements is again, highly inefficient.
Linked lists overcome all these problems such that no memory is ever in a redundant state, and no copying is ever required.
Source code for multilevel queue program in Java?
import java.io.*;
import java.util.*;
public class QueueImplement{
LinkedList<Integer> list;
String str;
int num;
public static void main(String[] args){
QueueImplement q = new QueueImplement();
}
public QueueImplement(){
try{
list = new LinkedList<Integer>();
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader bf = new BufferedReader(ir);
System.out.println("Enter number of elements : ");
str = bf.readLine();
if((num = Integer.parseInt(str)) == 0){
System.out.println("You have entered either zero/null.");
System.exit(0);
}
else{
System.out.println("Enter elements : ");
for(int i = 0; i < num; i++){
str = bf.readLine();
int n = Integer.parseInt(str);
list.add(n);
}
}
System.out.println("First element :" + list.removeFirst());
System.out.println("Last element :" + list.removeLast());
System.out.println("Rest elements in the list :");
while(!list.isEmpty()){
System.out.print(list.remove() + "\t");
}
}
catch(IOException e){
System.out.println(e.getMessage() + " is not a legal entry.");
System.exit(0);
}
}
}
A computer is a person or a machine that performs computations. An accountant is a computer (human computer). A slide-rule is a computer (an analog computer). A smart phone is a computer (digital computer).
Program to find reverse of given number using pointers?
#include
#include
void main()
{
int rev num=0;
while(num>0)
{
rev num=rev num*10+num%10;
num=num%10;
}
return rev_num;
}
int main();
{
int num=4562;
printf("reverse of number is%d",reverse digit(num));
getch();
return o;
}
What is storage claases in c language?
storage classes is important part of c language.WHENEVER we define any function in c program then we can call that in every definend class.
there are four types of storage class. these are...
1 AUTO OR AUTOMATIC STORAGE CLASS
2 REGISTER STORAGE CLASS
3 STATIC STORAGE CLASS
4 EXTERNALSTORAGE CLASS
1) The features of "AUTOMETIC" storage class are as under some conditions:
storage : storage will be in memory.
value : garbage value.
scope : scope is local to block to the variable.
life : till, controls remain within the block.
2) The featurs of "STATIC" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : Till control remains within the block.
3) The featurs of "REGISTER" storage class are as under some conditions:
storage : register.
value : garbage value.
scope : local to the block.
life : value persists between variable.
4) The feature of "EXTERNAL" storage class are as under some conditions:
storage : memory.
value : zero.
scope : local to block.
life : till controls remains within the block.
What is the use of 'pragma' in C language?
The #pragma directive is a compiler specific instruction. There are many things you can tell the compiler. For instance, the #pragma pack n directive tells the compiler to override the /Zpn command line argument and to use a new default structure packing value. To see all of the possible #pragma directives, go to online help, and index by #pragma directives, C/C++. You probably only need to type in #pra and then click on C/C++ to get this far.
Why does your 3 phase compressor run backwards some times?
a three phase motor is reversed by switching 2 of the 3 power leads (any two) something is switching the power leads on you
When does a function need an include directive?
A function requires an include directive whenever it makes use of a data type or function that cannot be forward declared, or where a forward declaration would be undesirable, and where a complete declaration of that type or function exists in another file.
That may sound far more complex than intended, but it's really quite simple. The include directive is a signal to the compiler that the specified file is to be inserted into your file in its entirety, just as if you'd typed all the code it contains by hand. This is clearly a huge time saver when it comes to common data types and functions, but how do you decide if an include directive is actually required or not? Simple: comment out the directive and attempt to compile. If it fails, the directive is required. The errors raised will indicate exactly what types or functions it exposes and where they are used.
Most C/C++ programmers split their declarations from their definitions. Declarations of functions and data types (including class declarations) are usually placed in a header file (.h), while the definitions of the functions are safely tucked away in a separate source file (.cpp). Programmers are rarely interested in the implementations -- the header should contain all the information necessary to make use of the functions and data types contained therein. But in order to compile, the source file must include the header file. And if the two files must include other files, then we generally place those directives in the header file thus ensuring that the header contains all the necessary information to allow it to be included in other files.
What is the command prompt that directs output from a program to a file?
You have to include one more file:
#include <fstream.h>
//Which is responsible for operations with files
//Then call a variable of stream type
main ()
{
ofstream out_stream;
//And use out_stream like you use cout
int data_X;
...
data_X >> out_stream;
...
}
Can you run java program in turbo c or c plus plus?
Turbo C++ pre-dates the earliest C++ standard, ISO/IEC 14882:1998 (informally known as C++98). As such it is impossible to write standards-conforming C++ programs in Turbo C++. In particular, it lacks template metaprogramming and exception handling both of which are central to C++., and there is no standard template library because it didn't exist at the time. It's also 16-bit which limits its memory usage to 64KB, although DPMI can extend that limit to some degree.
Development of Turbo C++ effectively ceased in 1994. It was later revived in 2006 with two separate releases, Explorer (the free version) and Professional, but none of its inherent problems were resolved and no further development took place. Embarcadero acquired the software from Borland in 2008 and support was discontinued in 2009.
Today, the free version of Turbo C++ still finds uses in educational institutes (primarily in Asia) despite the fact it's of no practical use in learning C++ let alone writing C++ programs.
Turbo C++ was succeeded by C++ Builder. The current stable release is v10.1 Berlin, released in 2016.
How does the Java programming language work?
Java uses a code-compiler, which does not create a machine-code, like normal Windows programs, but a byte-code, which the Java interpreter runs. It is like a mini-operating system, forming a layer between the operating system and the program code. This way, you can run Java programs on almost any platform. Main drawback is, that Java is slower than other languages. Consider using an other, platform dependent solution, if cross platform compatibility is not needed.
How do you Write a C program to print a Series of Odd Numbers and Even Numbers.?
Reference:http:cprogramming-bd.com/c_page2.aspx# strange number
Example problem using nested if statement in C programming?
if (i<0) if (j<0) printf ("i<0 and j<0");
else printf ("What's now? Where this else belongs to? It's i>=0 or i<0 and j>=0?");
The answer is:
if (i<0) if (j<0) printf ("i<0 and j<0");
else printf ("i<0 and j>=0");
Of course you can use brackets:
if (i<0) {
if (j<0) printf ("i<0 and j<0");
else printf ("i<0 and j>=0");
}
or
if (i<0) {
if (j<0) printf ("i<0 and j<0");
} else printf ("i>=0");