How parallel port is used in turbo c?
Parallel port is the most simplest port of computer to use. It is too simple to use in Turbo C++ .
there are two types of parallel ports of computer
1. SPP (standard parallel port) = 0x3bc
2. ECP (Enhanced communication port) or EPP(Enhanced parallel port) = 0x378
parallel port is divided into three ports
1. DATA port = 0x3bc OR 0x378
2. control port = 0x3bd OR 0x379
3. status port = 0x3be OR 0x37a
data port is consists of 8 pins and use 8 bit binary code for controlling..
D7 D6 D5 D4 D3 D2 D1 D0
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 = 255..................send 255 int as data for binary all 1s
D7 D6 D5 D4 D3 D2 D1 D0
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0 = 0..............send 0 int as data for binary all 0s
D7 D6 D5 D4 D3 D2 D1 D0
128 64 32 16 8 4 2 1
0 0 0 1 0 0 0 0 = 16............send 16 int as data for binary 1 in pin (D0)
D0= pin 2
D1= pin 3
D2= pin 4
D3= pin 5
D4= pin 6
D5= pin 7
D6= pin 8
D7= pin 9
outp(port,data); is the function use send data to the ports.
where ,
port is the integer value of port..... 0x378 or 0x3bc or 0x379 or 0x3bd or 0x37a or 0x3be.
data is an integer value to send ..ranges from 0 to 255
data=inp(port); is the function to receive input from port.
data is integer data .....0-255
port is the integer value of port..... 0x378 or 0x3bc or 0x379 or 0x3bd or 0x37a or 0x3be.
Example:
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main (void)
{
int data=0, portin=0x37a, portout=0x378;
//send 255 to port....using data pins.
data=255;
outp(portout,data);
//input from port using status pins...
data=inp(portin);
printf("\n%d",data);
getch();
}
In this way we control parallel port in turbo C++
What r conditional loops and unconditional loops in c?
A conditional loop will only continue to loop while the given condition is true:
while( i < 10 ) {
...
}
An unconditional loop either has no condition (a GOTO loop), or the condition is guaranteed to always evaluate to true:
while( true ) {
...
}
What are the Different categories of control structure?
there are three categories of control structure 1 sequential 2 selective 3 repetitive
Write a c program to add all numbers between 100 and 200 which contain the digit 5 along with steps?
#include
int main(void)
{
int a;
for(a=100;a<=200;a++)
{
if(a%10==5)
{
printf("%d\t",a);
}
}
}
Every high-level computer programming language contains a while statement?
Due to the rather large number of high-level programming languages, it's difficult to say with absolute certainty that they all include a while statement. However, as loopingconstructs are fundamentally made up of goto's and labels, I would be pretty amazed to find one that doesn't at least provide an equivalent, particularly as looping is so common.
It's interesting to note that there are some languages such as Scheme that are focused on purely functional programming. So even though looping can be done, it would most likely accomplish the same task using recursive functions instead.
How do you get the output12345 1234 123 12 1?
printf ("12345 1234 123 12 1\n");
... or, did you mean to do it with loops ? ...
int i, j;
for (i=5; i>0; i--) {
for (j=1; j<=i; j++) printf ("%d", j);
printf (" ");
}
printf ("\n");
What is the value of expression 72 divided by c?
There is not enough information available to answer this question. The result of 72 divided by c will be an error if c is zero (0), a positive number if c is positive, and a negative number if c is negative.
1.382 OR 0.000 or 2831
How do youuse the 'long' function in turbo c?
#include
#include
void main()
{
long 11;
clrscr();
cout<<"size of long="<
getch();
}
What is the difference between a disk and a tape?
Disk allows for writing and reading any part of the disk at any time. This allows us to be playing games, surfing the web, and listening to music all at the same time. If we were to do this on tape, we would be able to only access the things in order they were on the tape, or we would have to wait while it scans the tape for our music, looking for empty space so we could download that latest patch.
Tape is a great way to backup your data because it's pretty cheep and easily stored and moved, but its only real use is bulk reading and writing (batch processing) of large amounts of data and other similar processes.
Disks are prone to mechanical failure, but allow for reading and writing files much easier and quicker but for a cost.
Tape is still widely used in a cooperate setting for off-site backups and for internal backups as accessing time while looking for a file to recover are not a concern where getting the file for your presentation in 5 minutes needs to be instant.
A program in c to copy text file?
File Operations in C are accomplished by the use of pointers.Pointers are use to point to a particular memory location.File are read and written by using file pointers.The Keyword FILE is used to declare a file pointer.
The Complete Program for writing text to a file and saving it and copying it to a new location is given at http://c-madeeasy.blogspot.com/2011/07/program-in-c-to-write-data-to-file-and.html
Program for implementation of non recursive predictive parser?
Aim:
Parse the following grammar.
E --> E + T / T
T --> T * F / F
F --> ( E ) / id
Program:
#include
#include
#include
#include
void err(const char* s)
{
perror(s);
exit(0);
}
int factor()
{
int val,i;
char ch[0];
scanf("%s",ch);
switch(ch[0])
{
case '(':
val=expr();
scanf("%s",ch);
if(ch[0]!=')')
err("Missing closing paranthesis in factor.");
break;
default :{
for(i=0;i { if((ch[i]>'0')&&(ch[i]<='9')) continue; else err("Illegal character sequence in place of factor."); } val=atoi(ch); } } return val; } int term() { int val; char ch[10]; val=factor(); while(1) { scanf("%s",ch); if(ch[0]=='*') { val=val*factor(); } else break; } ungetc(ch[0],stdin); return val; } int expr() { int val; char ch[10]; val=term(); while(1) { scanf("%s",ch); if(ch[0]=='+') val=val+term(); else break; } ungetc(ch[0],stdin); return val; } main() { printf("\nEnter the expression: "); printf("\n Result: %d\n",expr()); } Output: nn@linuxmint ~ $ gcc rec.c nn@linuxmint ~ $ ./a.out Enter the expression: 5 * ( 3 + 1 ) ; Result: 20 nn@linuxmint ~ $
How to write program for secant method in mathematica?
How to write a program for secant method by mathematica
PROGRAM:
//LINEAR SEARCH USING FUNCTIONS
#include
void linear(int [],int,int);
main()
{
int n,i,x,a[10];
printf("\nEnter the limit:");
scanf("%d",&n);
printf("\nEnter the elements:");
for(i=0;i { scanf("%d",&a[i]); } printf("\nEnter the element to be searched:"); scanf("%d",&x); linear(a,n,x); } void linear(int a[],int n,int x) { int i,flag=0; for(i=0;i { if(x==a[i]) { flag=1; break; } } if(flag==1) printf("\nElement %d is in the position %d",a[i],i+1); else printf("\nElement is not in the list"); }
Does break statement terminate only the inner loop in c?
Yes. Break terminates only the innermost control structure, loop, switch, etc. If you want to break out of nested control structures, you can set a variable to induce a second break, or you can throw an exception.
This is a tricky one. The tripple 'ZZZ' indicates a location for source data. Start a file named 'Grade' (spead sheet). There are 3 sets of test scores to be logged. In this file all scores should be logged from highest to lowest.
short answer: executable code is a program that is ready to be used write now.
long answer:
writing a computer program is generally a 2 part process (there are exceptions):
1) programmer writes the code
2) programmer runs his code through a special program called a Compiler
the Compiler is responsible for taking code that a programmer can understand, and turning it into something that a computer can understand. executable code is (usually) code that has been compiled.
What is incomplete binary tree?
Incomplete Binary Tree is a type of binary tree where we do not apply the following formula:
1. The Maximum number of nodes in a level is 2
Why doesn't the main function need a prototype statement?
Because we usually don't call it from the program, but if we do, you should have a prototype:
int main (int argc, char **argv);
int foobar (const char *progname)
{
char *param[2];
...
param[0]= progname;
param[1]= "help";
main (2, param);
...
}
int main (int argc, char **argv)
{
...
foobar (argv[0]);
...
}