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

C program to returns the string, Program is to take two arguments and retur...

Program is to take two arguments and returns the string: Program is to take two arguments and returns the string which is larger the larger string has larger ascii value invok

How to insert values in array - c++ program, How to insert values in array ...

How to insert values in array - c++ program: Write a program to insert values in array void main() { int a[2][3][2]={                                 {

Memory management system, 1. Basic Heap: Each memory location in our model ...

1. Basic Heap: Each memory location in our model of the RAM will be an instance of type Memory: 2. typedef union Memory_u Memory; 3. union Memory_u{ 4. char character;

Decoding, how to decode a number from mobile keypad

how to decode a number from mobile keypad

Which one would you prefer - a macro or a function, Which one would you pre...

Which one would you prefer - a macro or a function? Actually it depends on the purpose of program! - In case of macros, corresponding code is inserted directly into your sou

Convert a cov-cpe file to a tif image file, Convert a COV/CPE (Micosoft Fax...

Convert a COV/CPE (Micosoft Fax Cover Page) file to a TIF image file Project Description: I would like a small API written that will take a COV/CPE file and replaced the corr

Program is to reverse the names stored in an array pointer, Program is to r...

Program is to reverse the names stored in an array pointer: Program is to reverse the 6 names stored in an array pointer as name[] void main()   {  clrscr();  char

Car rental project, I need a project on car rental system using c programmi...

I need a project on car rental system using c programming only of college level

Restart, how to create program in c that will system restart

how to create program in c that will system restart

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