Advantages and disadvantages of low level language?
Programs written in low level language are executed immediately. They require no compilers.
Low Level Language instructions can be used to manipulate the individual bits in a byte of computer storage.
DisadvantagesAre machine dependentdifficult to program.
Impossible for the programmer to memorize all the operational codes.
Correcting and modifying a program is difficult.
10 REM Sample BASIC Program - Counts To Ten 20 REM 30 REM Copyright 2005 Andrew Eichstaedt 40 REM Eichstaedt Development Group 50 REM http://www.andrew-eichstaedt.com 60 REM 70 PRINT "Hello! I am a sample BASIC program" 80 PRINT "that counts to ten." 90 PRINT 100 FOR I=1 TO 10 110 PRINT I 120 NEXT I 130 PRINT 140 PRINT "Thanks for running me." 150 END
C program to find prime number?
I am providing a succinct and easy to understand version of the program. I have run it in 3-4 compilers and it works perfect. Mind you, you should not enter a number more than 2147483647 (which is the largest number a variable can process in C!). If you do, no problem, but it will display all numbers above it, including the even numbers to be prime. So here you are:
#include
#include
main()
{
long int a,b,c;
printf("Enter the number: ");
scanf("%ld",&a);
An array name is a pointer constant?
An array's name is not a constant pointer; it's not even a pointer! An array name is a reference to the array itself. Unlike pointers, references have no memory of their own, therefore a reference cannot be constant (only what it refers to can be constant). A reference is nothing more than an alias for a memory address. Since there is no separate storage for references, you cannot reassign references while they remain in scope. So, in that sense, it behaves like a constant pointer. But a pointer is a variable, so even if declared const, it requires memory of its own in order to store the memory address it points to.
Example:
int a[10];
int * const p = a; // const pointer
assert( *p &a ); would cause an assertion. Likewise, assert( p != &p); proves that p must reside in a separate memory address from that referred to by a. It has to: pointers are variables even when they are declared const.
What are the Real time examples for non linear data structures?
In Systematically search option (Depth First Search), Data storing and retrieving in hard disk based on the "BALANCED TREE(AVL
- B- TREE)", printer (QUEUE),
In Programming language point of with out Data structure and Algorithms we can't develop a single program -
primitive data structures - INTEGER, FLOAT, CHAR , BOOLEAN, ETC..
abstract data structures- ARRAY , LINKED LIST , GRAPH, TREE, STACK , QUEUE. ETC..
So, In programming every where we are using without knowing about this...
try to learn basic thing about programming ....for to become a Good Software Engineer you should know the fundamental of Data Structure and Algorithms.
C program to find the second highest number from a set of numbers?
main()
{
in a,b,c,d;
printf("\n enter any four numbers");
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a==ba==cb==cb==dc==d)
printf("\n numbers must be different");
else
{
if(a>b&&a>c&&a>b)
X=b>c&&b>d?b;c>d?c:d;
else if(b>c&&b>d)
x=a>c&&a>b?a:c<d?c:d;
else if(c>d)
x=a>b&&a>d?a:b>d?b:d;
else
x=a>b&&a>c?a:b>c?b:c;
printf("\n %d is second max vaalue",x);
{
}
C program to print inverse of a given number?
Inversing of a given Number. suppose we gave input 123456 then the output of the program will be 654321./*mycfiles.wordpress.com
C program to print inverse of a given number*/
#include
#include
void main()
{
long int n,rn=0,d=0;
clrscr();
printf("Enter the number\n\n");
scanf("%ld",&n);
while(n>0)
{
d=n%10;
rn=rn*10+d;
n=n/10;
}
printf("%ld",rn);
getch();
}
What is a feature in c that is not in c plus?
C is a structured programming language which is feature of C which made it a powerful language when it was new in market.
But after C++ was developed structured programming was considered as disadvantage due to development of Object Oriented Programming Language.
In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements. Syntax
; token: : keyword identifierconstant string-literal operatorpunctuator The keywords, identifiers, constants, string literals, and operators described in this section are examples of tokens. Punctuation characters such as brackets ([ ]), braces ({ }), parentheses ( ( ) ), and commas (,) are also tokens.
C program to perform addition of matrices using functions?
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
const unsigned width = 4;
const unsigned height = 3;
class matrix
{
private:
vector< vector<unsigned> > m_data;
string m_title;
public:
matrix(string title=""): m_data(height, vector<unsigned>(width)), m_title(title) {}
matrix(const matrix& copy): m_data(copy.m_data), m_title(copy.m_title) {}
matrix& operator=(matrix rhs)
{
// Note: assignment does not overwrite the matrix title.
for(unsigned row=0; row<height; ++row)
for(unsigned col=0; col<width; ++col)
operator[](row)[col]=rhs[row][col];
return(*this);
}
vector<unsigned>& operator[](const unsigned index){return(m_data[index]);}
void set_title(const string title){ m_title = title; }
string& get_title(){return(m_title);}
void show()
{
cout<<m_title<<'\n'<<endl;
for(unsigned row=0; row<height; ++row)
{
for(unsigned col=0; col<width; ++col)
cout<<setw(7)<<(*this)[row][col];
cout<<endl;
}
cout<<endl;
}
matrix& operator+=(matrix rhs)
{
for(unsigned row=0; row<height; ++row)
for(unsigned col=0; col<width; ++col)
(*this)[row][col]+=rhs[row][col];
return(*this);
}
matrix operator+(matrix rhs)
{
matrix result(m_title+" + "+rhs.m_title);
for(unsigned row=0; row<height; ++row)
for(unsigned col=0; col<width; ++col)
result[row][col]=(*this)[row][col]+rhs[row][col];
return(result);
}
matrix& operator-=(matrix rhs)
{
for(unsigned row=0; row<height; ++row)
for(unsigned col=0; col<width; ++col)
(*this)[row][col]-=rhs[row][col];
return(*this);
}
matrix operator-(matrix rhs)
{
matrix result(m_title+" - "+rhs.m_title);
for(unsigned row=0; row<height; ++row)
for(unsigned col=0; col<width; ++col)
result[row][col]=operator[](row)[col]-rhs[row][col];
return(result);
}
};
unsigned input_num (std::string prompt)
{
unsigned id = 0;
while (1)
{
cout<<prompt<<": ";
string input="";
getline (cin, input);
stringstream ss (input);
if (ss>>id)
break;
cout<<"Invalid input.\n";
}
return (id);
}
void initialise(matrix& m)
{
for(unsigned row=0; row<height; ++row)
{
for(unsigned col=0; col<width; ++col)
{
stringstream ss;
ss<<"Enter a value for "<<m.get_title()<<'['<<row<<"]["<<col<<']';
m[row][col]=input_num(ss.str());
}
}
cout<<endl;
}
int main()
{
matrix matrix_1("matrix_1");
initialise(matrix_1);
matrix_1.show();
matrix matrix_2("matrix_2");
initialise(matrix_2);
matrix_2.show();
matrix matrix_3 = matrix_1 + matrix_2;
matrix_3.show();
matrix matrix_4 = matrix_3 - matrix_2;
matrix_4.show();
}
Which are the control structures in programming?
control structures are which is used to do some operations with conditions some of them are if,if else,switch,goto,continue..........and loops like for ,while,do while and even break used to break the process on some conditions
stdio.h files are used in c ,because "stdio" stands for standard Input and Output files .these headers is connect i/o device to the compiler
Write a program to draw a polygon using dda algorithm in c language?
# include <graphics.h> # include <math.h> # include <conio.h> # include <iostream.h> void DDALine(int x1,int y1,int x2,int y2,int iColor); void main() { int gDriver=DETECT,gMode; int x1,x2,y1,y2,iColor; initgraph(&gDriver,&gMode,"c:\\tc\\bgi"); cleardevice(); cout<<endl<<"Enter x1 : "; cin>>x1; cout<<"Enter y1 : "; cin>>y1; cout<<endl<<"Enter x2 : "; cin>>x2; cout<<"Enter y2 : "; cin>>y2; cout<<endl<<"Enter COLOR : "; cin>>iColor; cleardevice(); DDALine(320,1,320,480,12); DDALine(1,240,640,240,12); circle(320,240,2); DDALine(320+x1,240-y1,320+x2,240-y2,iColor%16); getch(); } void DDALine(int x1,int y1,int x2,int y2,int iColor) { float dX,dY,iSteps; float xInc,yInc,iCount,x,y; dX = x1 - x2; dY = y1 - y2; if (fabs(dX) > fabs(dY)) { iSteps = fabs(dX); } else { iSteps = fabs(dY); } xInc = dX/iSteps; yInc = dY/iSteps; x = x1; y = y1; circle(x,y,1); for (iCount=1; iCount<=iSteps; iCount++) { putpixel(floor(x),floor(y),iColor); x -= xInc; y -= yInc; } circle(x,y,1); return; }
Latest inventions in the field of computerized database?
Search Engines
iTunes
databases that are stored on the computer
A Constructor in java cannot have a return type. It always creates and returns an object of the class for which it is the constructor. You cannot return a value from a constructor explicitly and if you try to do that, the compiler will give an error. The system knows that the purpose of the constructor is to create an object of the class and it will do the same irrespective of whether you declare a return type or not.
What is difference between for loop and while loop?
One first basic rule is that you should use the for loop when the number of iterations is known. For instance:
The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.
The while loop can take every boolean expression as condition and permits therefore more complex end conditions. It is also the better choice if the iteration variable does not change evently by the same step or if there are more than one iteration variable. Even if you can handle more than one iteration variable in a for statement, the collections from which to choose the values must have the same number of elements.
Note: In C 'for' and 'while' can be easily replaced by each other:
while (exp) stmt
for (;exp;) stmt
for (exp1;exp2;exp3) stmt
{ exp1; while (exp2) { stmt exp3}}
Why can't we use C programming language for designing webpages?
No, you cannot. While it's possible that a web server may be written in C, an actual web page relies on HTML and various specialized languages (JavaScript, PHP, ASP, etc.) Note: You might write CGI-programs in C, if that's what you meant.
Write a program in C programming language that will add two integer numbers using linked list?
#include<stdio.h>
int add(int pk,int pm);
main()
{
int k ,i,m;
m=2;
k=3;
i=add(k,m);
printf("The value of addition is %d\n",i);
getch();
}
int add(int pk,int pm)
{
if(pm==0) return(pk);
else return(1+add(pk,pm-1));
}
</stdio.h>
Difference between while loop and do loop?
The difference between "do while" and "do until" is that a "do while" loops while the test case is true, whereas "do until" loops UNTIL the test case is true (which is equivalent to looping while the test case is false).
The difference between a "do ...while" loop and a "while {} " loop is that the while loop tests its condition before execution of the contents of the loop begins; the "do" loop tests its condition after it's been executed at least once. As noted above, if the test condition is false as the while loop is entered the block of code is never executed. Since the condition is tested at the bottom of a do loop, its block of code is always executed at least once.
To further clear your concept on this, understand the syntax and description of the two loop types:
while
The while loop is used to execute a block of code as long as some condition is true. If the condition is false from the start the block of code is not executed at al. The while loop tests the condition before it's executed so sometimes the loop may never be executed if initially the condition is not met. Its syntax is as follows.
while (tested condition is satisfied)
{
block of code
}
In all constructs, curly braces should only be used if the construct is to execute more than one line of code. The above program executes only one line of code so it not really necessary (same rules apply to if...else constructs) but you can use it to make the program seem more understandable or readable.
Here is a simple example of the use of the while loop. This program counts from 1 to 100.
#include
int main(void)
{
int count = 1;
while (count <= 100)
{
printf("%d\n",count);
count += 1; // Notice this statement
}
return 0;
}
Note that no semi-colons ( ; ) are to be used after the while (condition) statement. These loops are very useful because the condition is tested before execution begins. However i never seem to like these loops as they are not as clear to read as the do ...while loops. The while loop is the favorite amongst most programmers but as for me, i definitely prefer the do ...while loop.
do ....while
The do loop also executes a block of code as long as a condition is satisfied.
Again, The difference between a "do ...while" loop and a "while {} " loop is that the while loop tests its condition before execution of the contents of the loop begins; the "do" loop tests its condition after it's been executed at least once. As noted above, if the test condition is false as the while loop is entered the block of code is never executed. Since the condition is tested at the bottom of a do loop, its block of code is always executed at least once.
Some people don't like these loops because it is always executed at least once. When i ask them "so what?", they normally reply that the loop executes even if the data is incorrect. Basically because the loop is always executed, it will execute no matter what value or type of data is supposed to be required. The "do ....while" loops syntax is as follows
do
Note that a semi-colon ( ; ) must be used at the end of the do ...while loop. This semi-colon is needed because it instructs whether the while (condition) statement is the beginning of a while loop or the end of a do ...while loop. Here is an example of the use of a do loop.
include
int main(void)
{
}
For
Difference of c plus plus and fox pro?
C++ is a generic, general purpose, object-oriented, structured programming language used to produce native machine code programs. FoxPro is a procedural language and Database Management System (DBMS).
What process does thyroxin control?
Thyroxine is a hormone, or chemical messenger, that is secreted by the thyroid gland to help regulate metabolic processes and influence physical development of the body.
How do you solve declaration syntax error in c program?
The Turbo C++ compiler should tell you what the exact nature of the problem is since syntax errors are, by their very nature, compile-time errors. For instance, you may have made a typo when declaring one of the function's types, or forgotten to include the semi-colon to terminate the declaration. If any arguments are assigned default values, they must all be listed after all the arguments that do not have default values. And no two functions can have the same signature within the same scope or namespace.
Sum of digits of a number equals to the given number?
(I'm assuming base 10 math) You could cheat. Convert the number to a string with no leading zeros. Capture the left most and right most characters of the string. Convert captured string variables back to integers. Add the integers. (Note: Consider a base string having a string length of 0 or 1.)
Why arrays are easier to use compare to bunch of related variables?
wen d values are put in to a packet of array it is easier to use than a bunch of variables.. arrays have its built-in functions which makes its usage easier.