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

What are all of the implicit member functions of the class? , What are all ...

What are all of the implicit member functions of the class? Or what are all of the functions that compiler implements for us if we don't describe one? A: 1.      copy ctor

Online Tutor Available, I am an online tutor who can teach computer science...

I am an online tutor who can teach computer science and programming language. Is there any requirement for this?

Write down the code for binary search tree in c++?, A: BinarySearchTree.h ...

A: BinarySearchTree.h ---------------------- #ifndef BINARY_SEARCH_TREE_H_ #define BINARY_SEARCH_TREE_H_ #include "dsexceptions.h" #include // For NULL // Binary

What are the different steps in executing a c program, Question 1 What are...

Question 1 What are the different steps in executing a C program? Explain Question 2 What are the commonly used input/output functions in C? How are they accessed?

Store marks and name, Program is to store marks and name, roll no in a file...

Program is to store marks and name, roll no in a file: class stud   {     int rno;     char name[20];     int m1,m2,m3;     public:                 void acce

Defines the entry point for the console application, Defines the entry poin...

Defines the entry point for the console application. // #include "stdafx.h" #include #include #include"conio.h" using namespace std; double Determinant(double a[][3],int forde

C program for reverse the word in string, C Program for REVERSE THE WORD IN...

C Program for REVERSE THE WORD IN STRING #include conio.h> #include stdio.h> #include string.h> void main() {           char a[50],b[25][25],temp;           i

How private instance of a class can be assigned values, Question 1: (a)...

Question 1: (a) Explain clearly the following concepts using suitable examples of your own:- (i) concrete class v/s abstract class (ii) constructor v/s over

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