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

Which constructor gets called while i create an array of , Which constructo...

Which constructor gets called while I create an array of Fred objects?

Strings, write a c program to find input string using strlen(), strcpy(), s...

write a c program to find input string using strlen(), strcpy(), strcat(),strncat(), strcmp().

Is probable to encompass virtual constructor? if yes, Is it probable to enc...

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?

Area under the curve, Write a program to find the area under the curve y = ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Example., I need the c++ program of class bank accout including balance,rat...

I need the c++ program of class bank accout including balance,rate of interests

C program, what will be the c program for ideal gas equation.

what will be the c program for ideal gas equation.

Assigment, C++ Programming Assignment ATM Machine Phase 1 In this assign...

C++ Programming Assignment ATM Machine Phase 1 In this assignment you will create a program that allows a user to do the following: 1) Create a bank account by supplying a use

M--commerce, Project Description: We are aiming to prepare an industry f...

Project Description: We are aiming to prepare an industry first in the m-commerce world. M-commerce payment processing programmers required Skills required are C Programmi

Data structure and algorithm, implement two stacks in one array A[1...n] in...

implement two stacks in one array A[1...n] in such a way that neither stack overflows unless the total number of elements in both stacks together is n. For this you need to produce

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

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