data is required to be fed into the program


  Data is required to be fed into the program (input) and sent out of the program (output). Considering the draughtsman using a CAD station, the input is his commands to cause lines/circles to be drawn etc, the output is the actual drawing on the screen. General input is by means of the C command scanf. The syntax of the simplest input statement is: -

  scanf(" format of variable",&variable name)

e.g   scanf("%f",&number1);  expects a  floating number input
  scanf("%d",&number1);  expects a  integer number input
  scanf("%c",&number1);  expects a  single character  number  input
  scanf("%x",&number1);  expects a  hexadecimal number input
 
Note '&' means address operator.

Data is output by means of the printf command. The simplest syntax of the printf statement is: -
 
  printf(" string format  controls ",variables);
 
  printf("%f",number1);   prints a  floating number from the variable number1 
  printf("%d",number1);  prints a integer  number from the variable number1 
  printf("%c",number1);  prints a  single character from the variable number1 
  printf("%x",number1);  prints a  hexadecimal number

Within the syntax above we have mentioned 'controls' it is possible to include special screen controls in the format specification i.e. new line \n , carriage return \r, tabulate \t. 
 
  printf("%f\n\r",number1);   prints a  floating number from the variable number1 with a new line and carriage return  Likewise we can include a literal string within the format specification i.e. actual words  
 
printf(" The value is %f contained in the variable number1 \n\r",number1); 
  
This prints literal text and a floating number from the variable number1 with a new line and carriage return.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: data is required to be fed into the program
Reference No:- TGS0414631

Expected delivery within 24 Hours