Input/Output Statements in C PDF

Summary

This document provides an overview of input/output statements in C, focusing on formatted and unformatted I/O functions, escape sequences, and format specifiers. It also explains how scanf works and common data-loss scenarios.

Full Transcript

input/output statements with the help of stdio.h we can use printing and reading functionality formatted i/o fun- printf() , scanf() f--> formatted unformatted i/o fun- char- putchar(), getchar() string - puts() , gets() file/string - fputs(),fgets() printf() printf("control string",var1,const1,exp...

input/output statements with the help of stdio.h we can use printing and reading functionality formatted i/o fun- printf() , scanf() f--> formatted unformatted i/o fun- char- putchar(), getchar() string - puts() , gets() file/string - fputs(),fgets() printf() printf("control string",var1,const1,exp1,...); escape sequence char-- '\t' -- tab space 9 '\n' -- new line --10 '\v' -- vertical tab 11 '\b' -- backspace 8 '\a'-- alarm /bell 7 '\r'-- carriage return 13 '\f'--form feed 12 \" -- " \'-- ' '\\' --- \ '\?'-- ? every escape seq is having ascii value in control str at place of escape seq chr u can write the ascii value in octal or hexa decimal formate \n -- 10--> octal \0.... newlinw \012 hexadeci-- \x... for newline \xa **printf returns the length of the control string if any problem happens then -ve (-1) retur type - int formate specifiers %d decimal/int %o octal %x hexadecimal %c character %f float %lf double %Lf long double %u unsigned decimal value %i int/octal/hexa %p address %s string %e exponent %ld long int %uld unsigned long int scanf()-data loss is there scanf returns the number variable its reading returns -ve -1 on error wap to sub two num without using minus - arithmetic operator

Use Quizgecko on...
Browser
Browser