Input and output routines, C/C++ Programming

Assignment Help:

  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.


Related Discussions:- Input and output routines

Constants, explain about symbolic constants with examples

explain about symbolic constants with examples

Explain public and private members, Public, Private and Protected members: ...

Public, Private and Protected members: Class members can either be declared in public','protected' or in the 'private' sections of the class. But as one of the features of OOP i

I want a reverse engineer a .exe to obtain the code, I want a Reverse engin...

I want a Reverse engineer a .exe to obtain the code Project Description: I'd like to get the full C++ source code from a .exe please Skills required is C++ Programming

Link list, For this program you will add and test 2 new member functions to...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

#Padovan string, A Padovan string P(n) for a natural number n is defined as...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the c

What is b-tree, B-tree: A B-tree is an also called balanced m-way tree. A ...

B-tree: A B-tree is an also called balanced m-way tree. A node of the tree may have many records or key and pointers to children. It is also called as the balanced sort tree. It s

What is a union how does it differ from a structure, Question : (a) (i)...

Question : (a) (i) What is a structure member in C? What is the relationship between a structure member and the structure? (ii) How can structure variables be declared in C?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd