Skip to main content

ads1

Class 10th Chapter 12 Using I/O Operations

 Using I/O Operations


 
All programming languages allow to read input (known as input operations) and to write output (known as output operations).

Input/Output operations are more popularly known as I/O operations. The C language does not have any built-in statement to perform input and output operation.

C language does not have any built-in statement to perform input and output operation.

These data input and output operations are carried out by the standard input/output built-in library functions. So far we have used scanf() as a standard input and printf() as a standard output function in our programs.

I/O operations using functions like getchar), getch(), getso, scanfo, printf(), putcharo, putc(), puts(), etc.

To use any inbuilt function from C library, we have to include respective library of that function in the beginning of program using #include statement.

#include<stdio.h>

The name stdio.h stands for standard input-output header file. This header file contains various input and output operations related functions. The statement #include informs the compiler to find stdio.h file and place its contents in the beginning of our program.

getch() :- The function getch() is also used to read a character from the user.

gets(variable_name); The gets() function takes one string variable as an argument. Here variable_name is the character array.

scanf("control string", &variablel, &variable2, ....&variablen); The control string specifies the data format in which values of variables are to be stored.

The & sign is known as address of operator in C language and it specifies the memory location where the input given by user is stored.

• Escape sequence characters like \n (new line), \t(tab), \b(back space) Like scanf( ), the control string entries are separated by space and preceded by '%'. The later part of printf() contains list of variables whose values are to be printed.


 
Choose the correct option from the following :

(1) Which of the followings are useful in C language I/O operations ?
(a) Monitor
(b) Keyboard
(c) Mouse
(d) All of these

(2) Input in a program can be possible using which of the following device ?
(a) Keyboard
(b) Speaker
(c) Printer
(d) Monitor

(3) Which of the following is not an input functions ?

(a) getchar()
(b) getch()
(©) puts()
(d) gets()
 
 
(4) What is the output of statement: printf("%4s", "Krusha"); ?
(a) Krus
(b) usha
(c) Krusha
(d) Krush

(5) Which of the following function is more appropriate for accepting a string ?
(a) getch()
(b) gets()
(c) getchar()
(d) getc()



ads2

Popular posts from this blog

11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following:

    11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following: Basic Salary <= 10000 : HRA = 20%, DA = 80% Basic Salary <= 20000 : HRA = 25%, DA = 90% Basic Salary > 20000 : HRA = 30%, DA = 95% Static Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     if(basic <=10000)     {         da = basic * 0.8;         hra = basic *0.2;     }              else if(basic <=20000)     {         da = basic * 0.9;         hra = basic *0.25;     }     else     {         da = basic * 0.95;         hra = basic * 0.3;     }     gross = basic + da + hra;     System.out.println("The Gross Salary is :-"+gross);     } } Output :-  Dynamic Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     Scanner in = new Scanner(System.in);     System.out.println("Enter the Basic Salary

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise or class wise.

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise  or class wise. Solution :-   # x-axis is shows the subject and y -axis # shows the markers in each subject # import pandas and matplotlib  import pandas as pd  import matplotlib.pyplot as plt # Simple Line Chart with setting of Label of X and Y axis, # title for chart line and color of line  subject = ['Physic','Chemistry','Mathematics', 'Biology','Computer'] marks =[80,75,70,78,82] # To draw line in red colour plt.plot(subject,marks,'r',marker ='*')     # To Write Title of the Line Chart plt.title('Marks Scored') # To Put Label At Y Axis plt.xlabel('SUBJECT')           # To Put Label At X Axis plt.ylabel('MARKS')             plt.show() Output :- 

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category. import pandas as pd  # initialize list of lists data = [['CAR','Maruti',1000000],['AC','Hitachi',55000],['AIRCOLLER','Bajaj',12000], ['WASHING MACHINE','LG',15000],['CAR','Ford',7000000],['AC','SAMSUNG',45000],['AIRCOLLER','Symphony',20000],['WASHING MACHINE','Wirlpool',25000]] Col=['itemcat','itemname','expenditure'] # Create the pandas DataFrame qrtsales = pd.DataFrame(data,columns=Col) # print dataframe.  print (qrtsales) qs=qrtsales.groupby('itemcat')  print('Result after Filtering Dataframe')  print(qs['itemcat','expenditure'].sum()) Output :-