Difference between blank space and white space?
In computer programming, these two terms are interchangeable.
Why is a text editor used to write high level language?
because it would be hard to write software using a duck. ducks make terrible input devices.
Who invented c the programming language?
Dennis Ritchie "offically" created the C programming language while working at Bell labs. However, Ken Thompson should also be mentioned since he created a slightly lesser known language called B which is the basis of the C language. Ritchie added "types" and other changes but kept most of B's syntax.
How do you write elevator program in c language?
/*This is a simple Program*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
int main()
{
int curfl = 0, destfl, floor;
float high, speed;
float time1;
high = 3.0; // Height of the floor
speed = 5.0; // Speed of the elevator per second
while(1)
{
printf("Currently the elevator is at floor number = %d\n", curfl);
printf("Enter the floor number between 0-25 : ");
// printf("%d %d", &curfl, &time1);
scanf("%d", &destfl);
if(destfl > curfl)
{
floor = destfl - curfl;
time1 = (floor * (high / speed));
printf("Elevator will take %.2f second to reach %d (st, nd, rd) floor \n", time1, destfl);
while(curfl != destfl)
{
Sleep((1000 * 3) / 5);
curfl++;
printf("You are at floor number %d \n", curfl);
}
printf("Door opening \n");
Sleep(10000);
printf("Door Closed\n \n");
}
else if(destfl < curfl)
{
floor = curfl - destfl;
time1 = (floor * (high / speed));
printf("Elevator will take %.2f second to reach %d (st, nd, rd) floor \n", time1, destfl);
while(curfl != destfl)
{
Sleep((1000 * 3) / 5);
curfl--;
printf("You are at floor number %d \n", curfl);
}
printf("Door opening \n");
Sleep(10000);
printf("Door Closed\n \n");
}
else{
printf("You are the same floor. Please getout from the elevator \n");
}
}
// printf("Hello world!\n");
return 0;
}
How did copy string one variable to another variable in body of the program in c?
1.Write a c program for Fibonacci series?
/*program to calculate factorial of a number*/
#include<stdio.h>
#include<conio.h>
void main()
{
long int n;
int a=1;
clrscr();
printf("enter the number=");
scanf("%ld",&n);
while(n>0)
{
a*=n;
n--;
}
printf("the factorial is %ld",a);
getch();
}
What is self introduction for computer programmer?
A self introduction is when a person introduces themselves to another person or group. A computer programmer would begin by stating their name, state their interests and skill sets in programming.
[ string toupper $str ] or [ string tolower $str ]
How do you write c program to identify keywords using transition table?
#include
#include
#include
void keyw(char str[10])
{
if(strcmp("for",str)==0)
printf("%s is a keyword",str);
else if(strcmp("while",str)==0)
printf("%s is a keyword",str);
else if(strcmp("char",str)==0)
printf("%s is a keyword",str);
else if(strcmp("int",str)==0)
printf("%s is a keyword",str);
else if(strcmp("if",str)==0)
printf("%s is a keyword",str);
else if(strcmp("else",str)==0)
printf("%s is a keyword",str);
else
printf("%s is an identifier",str);
printf("\n");
}
main()
{
FILE *f1,*f2,*f3;
char c,str[10];
int num[100],ln=0,tvalue=0,i=0,j=0,k=0;
printf("Enter a C program expression");
f1=fopen("input.c","w");
while((c=getchar())!=EOF)
fputc(c,f1);
f1=fopen("input.c","r");
f2=fopen("identifier.txt","w");
f3=fopen("specialchars.txt","w");
while((c=fgetc(f1))!=EOF)
{
if(isdigit(c))
{
tvalue=c-'0';
c=fgetc(f1);
while(isdigit(c))
{
tvalue=tvalue*10+c-'0';
c=fgetc(f1);
}
num[i++]=tvalue;
ungetc(c,f1);
}
else if(isalpha(c))
{
fputc(c,f2);
c=fgetc(f1);
while((isdigit(c))isalpha(c)c==' 'c=='$')
{
fputc(c,f2);
c=fgetc(f1);
}
fputc(' ',f2);
ungetc(c,f1);
}
else if(c==' 'c=='\t');
else if(c=='\n')
ln++;
else
fputc(c,f3);
}
fclose(f1);
fclose(f2);
fclose(f3);
printf("Numbers in the program are \n");
for(j=0;j
printf("%d",num[j]);
printf("\n");
f2=fopen("identifier.txt","r");
k=0;
while((c=fgetc(f2))!=EOF)
{
if(c!=' ')
str[k++]=c;
else
{
str[k]='\0';
keyw(str);
k=0;
}
}
fclose(f2);
f3=fopen("specialchars.txt","r");
printf("The special chars in the pgm are \n");
while((c=fgetc(f3))!=EOF)
printf("%c",c);
printf("\n");
fclose(f3);
}
What is the use of Bitwise operators?
The bitwise operators treat a number as its binary equivalent rather than as a simple boolean value.
For most programming languages, a value of zero is considered FALSE and all other values are TRUE
Thus, 8 AND 11 returns TRUE as does 3 OR 0
In bitwise analysis, each binary bit of the digit are compared. The number of bits compared will depend on the type of number.
In C, a CHAR is usually 8 bits and can hold the binary numbers 0 to 255.
If we compare 8 (00001000) and 19 (00010011) with bitwise operators, we get different results from Boolean operators:
8 BITWISE AND 19 returns 0 (each bit in the response is set to 1 if both equivalent bits compared are 1) but 8 BITWISE OR 19 will return 27.
The utility of these methods is in identifying binary data. For example, all files on a PC have the characteristics 'Hidden' 'Read Only' 'Archive' and 'System' which can be set or unset using bitwise operations on a single byte of data. In truth this is a throwback to the days of small memory capacities where saving the odd byte was essential.
There are more uses of bitwise, especially in graphics, where XOR can be used to paint a sprite image to display it and then be used again to return a background to its former settings. I regret I lack the skill to explain this better.
How do you calculate the LCF of two numbers using a function?
You do not need a function to determine the lowest common factor of two numbers. The lowest factor of any one number is 1. The lowest common factor of any two numbers is therefore 1 as well.
Difference between pop and push operation in data structure through c?
Pushing means putting an item onto a stack (data structure), so that it becomes the stack's top-most item. Popping means removing the top-most item from a stack. (You often hear a third term, peeking, which means looking at/reading the top-most item.)
When it comes to queues, you should generally use the terms enqueueing and dequeueing instead, where the former means appending an item to a queue's "back end" and the latter means removing the item at the "front end" from the queue.
These definitions suggest that a stack (if you picture it in your head) is spatially vertical, while a queue is horizontal. Another difference is that operations on a stack always happen at the same end, while operations on a queue happen at opposite ends.
When it comes to linked lists and double-ended queues (deques), the terms push and pop are also used, e.g. in C++'s STL, where you have operations such as push_front, push_back, pop_front, and pop_back. These simply imply that items can be appended or removed at both ends.
With the help of a program explain the depth first traversal of a tree?
Refer to the following code and example output below.
#include<iostream>
#include<time.h>
#include<queue>
#include<stack>
class tree
{
private:
struct node
{
static unsigned s_id; // static id
unsigned id; // instance id
unsigned data; // instance data
unsigned depth; // depth of node
node* left; // pointer to left node (may be NULL)
node* right; // pointer to right node (may be NULL)
node (unsigned num, unsigned depth): data (num), left (NULL), right (NULL), id (s_id++), depth (depth) {}
~node () { delete (left); delete (right); }
void insert (unsigned num)
{
if (num < data)
{
if (!left)
left = new node (num, depth+1);
else
left->insert (num);
}
else
{
if (!right)
right = new node (num, depth+1);
else
right->insert (num);
}
}
void print ()
{
std::cout<<"ID: "<<id<<" Depth: "<<depth<<" Data: "<<data<<std::endl;
}
void print_sorted ()
{
if (left)
left->print_sorted ();
print();
if (right)
right->print_sorted ();
}
};
node* m_root;
public:
tree (): m_root (NULL) {}
~tree (){ delete (m_root); }
void insert (unsigned num)
{
if (!m_root)
m_root = new node (num, 0);
else
m_root->insert (num);
}
void print_sorted ()
{
std::cout<<"Sorted-order traversal\n"<<std::endl;
if (m_root)
{
m_root->print_sorted ();
std::cout<<std::endl;
}
}
void print_breadth_first ()
{
std::cout<<"Breadth-first traversal\n"<<std::endl;
std::queue<node*> q;
if (m_root)
{
// enque the root
q.push (m_root);
// repeat while the queue is not empty
while (!q.empty ())
{
// dequeue the first node
node* n = q.front ();
q.pop ();
// report the node
n->print ();
// enqueue left and right nodes
if (n->left)
q.push (n->left);
if (n->right)
q.push (n->right);
}
std::cout<<std::endl;
}
else
std::cout<<"The tree is empty!\n"<<std::endl;
}
void print_depth_first ()
{
std::cout<<"Depth-first traversal\n"<<std::endl;
std::stack<node*> s;
if (m_root)
{
// stack the root
s.push (m_root);
// repeat while the stack is not empty
while (!s.empty())
{
// unstack the top node
node* n = s.top ();
s.pop ();
// report the node
n->print ();
// stack left and right nodes
if (n->right)
s.push (n->right);
if (n->left)
s.push (n->left);
}
std::cout<<std::endl;
}
else
std::cout<<"The tree is empty!\n"<<std::endl;
}
};
// initialise static data
unsigned tree::node::s_id = 0;
int main()
{
srand((unsigned) time(NULL));
// create tree with 10 random numbers
tree t;
for(unsigned i=0; i<10; ++i)
t.insert (rand ());
t.print_sorted ();
t.print_breadth_first ();
t.print_depth_first ();
}
Example output:
Sorted-order traversal
ID: 6 Depth: 2 Data: 334
ID: 4 Depth: 1 Data: 2335
ID: 0 Depth: 0 Data: 12490
ID: 5 Depth: 4 Data: 15590
ID: 9 Depth: 5 Data: 18484
ID: 3 Depth: 3 Data: 23160
ID: 2 Depth: 2 Data: 23786
ID: 8 Depth: 3 Data: 24171
ID: 1 Depth: 1 Data: 24598
ID: 7 Depth: 2 Data: 30731
Breadth-first traversal
ID: 0 Depth: 0 Data: 12490
ID: 4 Depth: 1 Data: 2335
ID: 1 Depth: 1 Data: 24598
ID: 6 Depth: 2 Data: 334
ID: 2 Depth: 2 Data: 23786
ID: 7 Depth: 2 Data: 30731
ID: 3 Depth: 3 Data: 23160
ID: 8 Depth: 3 Data: 24171
ID: 5 Depth: 4 Data: 15590
ID: 9 Depth: 5 Data: 18484
Depth-first traversal
ID: 0 Depth: 0 Data: 12490
ID: 4 Depth: 1 Data: 2335
ID: 6 Depth: 2 Data: 334
ID: 1 Depth: 1 Data: 24598
ID: 2 Depth: 2 Data: 23786
ID: 3 Depth: 3 Data: 23160
ID: 5 Depth: 4 Data: 15590
ID: 9 Depth: 5 Data: 18484
ID: 8 Depth: 3 Data: 24171
ID: 7 Depth: 2 Data: 30731
Each node reports its ID, depth and data. The ID tells us the sequence the nodes were created, where the node with ID 0 is always the root. The depth tells us the level within the tree where the node exists, such that the root is on level 0. With this information it is possible to draw a graph of the tree and thus better understand the order in which nodes are processed.
The first listing shows the nodes in ascending order by data. With binary search trees this is the normal method of traversal.
The second listing shows a breadth-first traversal, where each level is processed in turn, from left to right.
The final listing shows a depth-first traversal where we follow left nodes before right nodes.
You will notice that the implementation of breadth-first and depth-first are fairly similar, the only real difference being that breadth-first employs a queue while depth-first employs a stack. The nature of a stack also means we must push right nodes before left nodes to ensure left nodes are processed before right nodes.
At first glance there doesn't appear to be much merit in either breadth-first or depth-first traversal. However, the example merely serves to show the difference between all the methods of traversal. When considering more complex graphs or maps, it may be advantageous to search through all the vertices that form an edge with a particular vertex (breadth-first) or to examine all the edges between one vertex and another vertex, where several routes might be available (depth-first). Both depth-first and breadth-first have practical applications in network routing and satellite navigation, where maps and charts must be graphed and traversed in a more logical manner than would otherwise be possible with sorted-order traversal.
How do you find the largest and the smallest values among 4 numbers using conditional operators?
int a, b, c, d, max, min;
scanf("%d%d%d%d",&a, &b, &c, &d);
(a>b)?(max=a,min=b):(max=b,min=a);
(c>d)?(a=c,b=d):(a=d,b=c);
max=(a>max)?a:max;
min=(b<min)?b:min;
printf("%d %d\n", max, min);
Direct access.
AS
Why Linux operating system is written in c language?
Because Linux is "sort-of-a-copy-of-Unix" (which is not), and Unix was written in C.
C was created to write Unix. Most portable operating systems or serious embedded devices are written in some incarnation of C and C++. Including MS-DOS and earlier copies of Window$ (which I am sure still uses it)
What is the meaning of c c camera?
CC Camera is a small camera that is put up in Banks, Shopping Malls which are very small and many a times go un-noticed. The recordings of the CC Camera are only viewed when there is some theft or crime.
printf ("x")
When was the C and C Grocery in Jacksonville FL?
My father was an employee of the C & C grocery from the 1940's thru the
1960's. I don't know when they first opened nor when they closed down.
Mr Compton, who treated my father like a son, owned the stores.
Is syntax error a compilation error?
Not entirely. A compilation error can contain a syntax error, but what a syntax error actually is, is an error in how the coding is spelled. For example, say you are trying to program a router. You type in the code, of which you know it's the correct code, but receive an error. You proofread the code and notice that one or more of the words are not spelled correctly. This would be a syntax error. They can also take the form of misplacing the words in the code's syntax.
How do you get sound on an ideas emulator?
It took me a while to figiure it out, but the newer versions of the direct sound plugin are skippy, while it's not perfect try the 1.0.1.0 aud.dll DirectSound Audio Plugin. Browse for it on google that's the easiest way. It took me a while to figiure it out, but the newer versions of the direct sound plugin are skippy, while it's not perfect try the 1.0.1.0 aud.dll DirectSound Audio Plugin. Browse for it on google that's the easiest way.
What does a computer do when you first turn it on?
The first thing a computer does when you turn it on is check the BIOS to see which device it should boot from. It then finds the bootloader on that device (usually the hard disk), and runs it. The bootloader typically finds the operating system and starts that. And the operating system does various things when starting, such as starting certain programs that are set to load on startup.
chonit c. ymbong is a person and is not a what...
it's not a program or something but maybe he/she is an it student or graduate...
or maybe he/she could be a programer...
try checking out friendster.com...
he/she is their with somebody else's picture...