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.
Why does the height affect the loop on a marble rollercoaster?
I would have gravitational potential energy, which is energy due to height.
Which statements are nedded to control loop?
A For loop requires 3 parameters:
for( int i = 0; i < 10; ++i )
{
}
So, the first parameter - int i = 0 - shows the integer that you will be using to cycle with. This variable sometimes corresponds with what you're cycling through, so if you're using an array, array notation dictates that you can access the array with integers.
The second parameter - i < 10 - says that if the i variable is less than 10, do the for loop.
The third parameter - ++i - shows by how many you want to increment or decrement the variable by. This means that the for loop I have provided will run 10 times. (Remember: if you start at 0 - which all arrays and vectors e.t.c will do - you need to start your For loop at 0)
What is the difference between assembly language program and high level language program?
There is very little difference, functionally, between assembly language and machine level language. Each assembly language statement corresponds to one machine instruction. The difference is in readability (who wants to read and write in hex code?) and in ease of address computation.
What is pseudocode in c language how is it different from algorithm?
They are not similar. However one is used to write the other so the question is do you write
1) pseudo code with algorithm
2) an algorithm with pseudo code
3) with a pencil
What is mean by parse in java?
It is used to convert the value of one datatype into a value of another datatype. Example- Integer.parseInt(in.readLine); It converts given value to Integer datatype.
Write program to implement stack with POP and PUSH operations?
SOURCE CODE:
#include
#include
void push(int st[],int data,int &top);
void disp(int st[],int &top);
int pop(int st[],int &top);
int flg=0;
int top=-1,tos=-1;
int st[50];
void push(int st[],int data,int &top)
{
if(top==50-1)
flg=0;
else
{
flg=1;
top++;
st[top]=data;
}
}
int pop(int st[],int &top)
{
int pe;
if(top==-1)
{
pe=0;
flg=0;
}
else
{
flg=1;
pe=st[top];
top--;
}
return(pe);
}
void disp(int st[],int &top)
{
int i;
if(top==-1)
{
printf("\nStack is Empty");
}
else
{
for(i=top;i>=0;i--)
printf("\t%d",st[i]);
}
}
void main()
{
int dt,opt;
int q=0;
clrscr();
printf("This Program Is Used to Perform PUSH & POP operations On Stack");
printf("\n\n\tMain Menu.........");
printf("\n\n1.Push");
printf("\n\n2.Pop");
printf("\n\n3.Exit");
do
{
printf("\n\n\tEnter Your Choice 1-3:");
scanf("%d",&opt);
switch(opt)
{
case 1:
printf("\nEnter the Element to be Push:");
scanf("%d",&dt);
push(st,dt,tos);
if(flg==1)
{
printf("\nAfter Inserting the Element, Stack is:\n\n");
disp(st,tos);
if(tos==50-1)
printf("\nStack is Now Full");
}
else
printf("\nStack Overflow Insertion Not Possible");
break;
case 2:
dt=pop(st,tos);
if(flg==1)
{
printf("\n\tData Deleted From the Stack is:%d\n",dt);
printf("\n\tAfter Deleting the Element from the stack is:\n\n");
disp(st,tos);
}
else
printf("\nStack Empty,Deletio Not Possible:");
break;
case 3:
q=1;
break;
default:printf("\nWrong Choice Enter 1-3 Only");
}
}while(q!=1);
}
OUTPUT
Main Menu.........
1.push
2.pop
3.exit
Enter your choice 1-3:1
Enter the element to be push:4
After inserting the elements,stack is:
4
Enter your choice 1-3:1
Enter the element to be push:7
After inserting the elements,stack is:
7 4
Enter your choice 1-3:1
Enter the element to be push:4
What conditions must be satisfied by the entire elements of any given array?
All elements of any given array must satisfy the same data type requirement, meaning they should be of the same data type for the array to be well-defined and properly utilized.
How do you draw shapes in a c program?
With platform-dependent library-functions. Use your help system.
Is the loop control variable initialized after entering entering the loop?
Uninitialised variables take on whatever value happens to reside at the memory address to which the variable was allocated at the point of instantiation. It is a "garbage value" because we cannot predict what the initial value will actually be at runtime. All variables must be initialised before they are used (read); if we use an uninitialised variable our program has undefined behaviour.
Ideally, initialisation should always occur at the point of instantiation. However, there can be valid reasons for delaying initialisation. For instance, when we read data from a disk file into a memory buffer, it doesn't make any sense to waste time initialising the buffer with values we're about to overwrite:
void read_file (std::ifstream& file) {
char buffer[1024]; // uninitialised!
while (file.good()) {
size_t index=0;
while (file.good() && index<1024) {
file >> buffer[index++]; // fill the buffer one character at a time
}
if (!file.good()) {
if (file.eof()) --index; // index is off-by-one, so adjust
else throw std::exception ("Unknown error in read_file()");
}
// use the buffer...
}
}
In the above example, index is used as a loop control variable in the inner loop and ultimately tells us how many characters were read into the buffer (such that index<=1024 upon exiting the inner loop). If EOF was reached, index will be off by one because we attempted to read one more character than actually exists, so we decrement accordingly. We could handle other read errors here but, for the sake of brevity, we throw an exception and let the caller deal with it. Assuming no read errors occurred, we can safely use the buffer (all indices less than index are valid). If the file contains more than 1024 characters, the next iteration of the outer loop will overwrite the buffer, so there's no need to flush it.
Now, consider what happens if we (accidently) fail to initialise index with the value 0:
void read_file (std::ifstream& file) {
char buffer[1024]; // uninitialised!
while (file.good()) {
size_t index; // WARNING: uninitialised
while (file.good() && index<1024) {
file >> buffer[index++]; // fill the buffer one character at a time
}
if (!file.good()) {
if (file.eof()) --index; // index is off-by-one, so adjust
else throw std::exception ("Unknown error in read_file()");
}
// use the buffer...
}
}
This code has undefined behaviour. Hope for a compiler warning!
If we suppose that the code compiles without warning (or we unwisely choose to ignore such warnings), there are several possible outcomes. Note that it is reasonable to assume that index will always be allocated the same address so, regardless of the initial value, it will hold whatever value was generated upon the previous iteration of the inner loop.
1. If index happens to hold the (correct) value zero, then the inner loop will read up to 1024 characters. However, any subsequent iteration will incur undefined behaviour because index would then be 1024 which is beyond the valid range of buffer.
2. If index happens to hold a value greater than zero but less than 1024, all characters before buffer[index] will remain uninitialised. Upon exiting the inner loop, there is no way to determine where writing began and index will tell us we've read more characters than were actually read. Any subsequent iteration will incur undefined behaviour because index would then be 1024 which is beyond the valid range of buffer.
3. If index happens to hold a value greater than or equal to 1024, the inner loop will never execute (nothing will be read from the file), thus file.good() can never become false and the outer loop becomes an infinite loop. Any attempt to read buffer[index] or any value beyond buffer[1023] incurs undefined behaviour.
Difference between if and switch in C?
The switch statement evaluates an expression, which must have an integral result. Based on that result, a branch is taken to one of the case statements, or to the default statement if present and none of the case statements match.
Note that the case statement represents a "goto" type of operation. If it is intended that each case execute without executing the following case statement(s), then each case must include a break statement.
The if-else statement evaluates an expression, which must have a logical result. If the result is true, the first target statement executes - if false, the second target statement executes.
What is the difference between float and double in c language?
float is a primitive datatype in java that is used to hold numeric values that contain decimal places.
Ex: float f = 10;
The above is an example declaration of a float variable. They can be used in all arithmetic operations like addition, subtraction, multiplication, division etc.
It uses 32 bits and there is as such no minimum or maximum value it can take. The value that a float can hold is larger than all possible numeric values that we can use in our systems (in most cases)
Why you use C when C plus plus is there?
C is a much simpler language than C++, with fewer keywords. The resultant machine code maps very closely to the source code, thus C is more low level than C++, but is sufficiently abstract that even assembler language programmers can develop highly efficient code much more easily than they can with assembler alone. C++ evolved from C, but has a far greater degree of abstraction and its object-oriented programming support is ideally suited to solving highly complex problems with more complex data structures more easily but every bit as efficiently as with C. However, since C is much older, there is still a wealth of useful and highly efficient C code that can still be used by C++ programmers to this day, thus it is still worthwhile learning C even if you already know C++, as the transition to C is much easier than the transition from C to C++, unless you are familiar with object-oriented principals.
Write a C Program to accept 5 names from user and store these names into an array?
/*Program to accept names of 5 students and display them in alphabetic order*/
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
int i=0,j=0;
char frame[5],temp[5];
clrscr();
for(i=0;i<4;i++)
{
printf("\nEnter student[%d]string",i);
scanf("%s",fname[1]);
}
for(i=0;i<=4;i++)
{
for(j=i+1;j<=4;j++)
{
if(strcmp(fname[i],fname[i])>0)
{
strcpy(temp,fname[i]);
strcpy(fname[i],fname[i]);
strcpy(fname[j],temp);
}
}
}
printf("The names of the students in alphabetic order is:");
for(i=0;i<=4;i++)
{
printf("\n%s",fname[i]);
}
getch();
}
What is the use of base pointer register?
It contains an address, which will be used in calculting the actual address of an operand.
Example (Sytem/360): L R2,12(R3,R4)
meaning:
tempadd := 12 + R3 + R4
R2 := content of memory at tempadd
here R3 is called base registed, R4 is called index register. Or vice versa.
What function initializes variables in a class?
you have to initialize it into the "Constructor" which is a function without dataType and it's name is the same with the class name
EX:-
class Exforsys
{
private:
int a,b;
public:
Exforsys();
...
};
Exforsys :: Exforsys()
{
a=0;
b=0;
}
the EX from : http://www.exforsys.com/tutorials/c-plus-plus/class-constructors-and-destructors-in-c.html
I recommend this link for You Under the title "Constructors and destructors" :
http://www.cplusplus.com/doc/tutorial/classes/
You can also See : http://www.win.tue.nl/~maubach/university/education/online-references/cpp/swartz/notescpp/oop-condestructors/constructors.html
What are system variable in management information system?
is quantity or item controlled by the decision maker.