This document discusses standard input/output functions in C language. It provides examples of functions like printf(), scanf(), gets(), puts() to take input from keyboard and display output. It explains format specifiers like %d, %f used with these functions. Escape sequences and functions like getch(), getche(), clrscr() for character input and screen clearing are also covered along with examples.
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
Introduction to control structure in C Programming Language include decision making (if statement, if..else statement, if...else if...else statement, nested if...else statement, switch...case statement), Loop(for loop, while loop, do while loop, nested loop) and using keyword(break, continue and goto)
A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
Fundamental of C Programming Language
and
Basic Input/Output Function
contents
C Development Environment
C Program Structure
Basic Data Types
Input/Output function
Common Programming Error
Understand basic concept of c programming with more than 100 error free programs. use of header file and different symbols in c programs. for better and complete understanding login to www.eakanchha.com
This is a presentation on C language. Brief description on C language
Topics Covered
What is C
Header files in C
What is main function in c
Basic Structure of C
Keywords & Identifiers
Data Types & Variable Declaration in C Includes | Format Specifier | Memory Size
Input in C (printf() scanf() function)
Operators in C: Asthmatics,Increment Decrement, Relational, Logical operators
Sample Exercise
LinkedIn: https://www.linkedin.com/in/shamsulhusainansari/
GitHub: https://github.com/shamsulhusainansari
structure of c program. everything about the structure is in this ppt...................................................................viearhgviuehdrgbvkejfsdbvaerhbgf;oiweHFGIO;WENEGV;KLADFN;OVIBNA;OINVO;IRANV;OINDF;LNVOIASRDNGVIOERNAVB EOANGVV ERNGOEWN
Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.
C language has a series of standard input-output (I/O) functions. Such I/O functions together form a library named stdio.h. Irrespective of the version of C language, user will have access to all such library functions. These library functions are classified into three broad categories.
a) Console I/O functions : Functions which accept input from keyboard and produce output on the screen.
b) Disk I/O functions : Functions which perform I/O operations on secondary storage devices like floppy disks or hard disks.
c) Port I/O functions : Functions which perform I/O operations on various ports like printer port, mouse port, etc.
Console I/
Programming Fundamentals Functions in C and typesimtiazalijoono
Programming Fundamentals
Functions in C
Lecture Outline
• Functions
• Function declaration
• Function call
• Function definition
– Passing arguments to function
1) Passing constants
2) Passing variables
– Pass by value
– Returning values from functions
• Preprocessor directives
• Local and external variables
This slide constitutes of knowledge about how to use C language. Every programmer should be equipped with this basic knowledge before he/she starts programming with C.
It is an attempt to make the students of IT understand the basics of programming in C in a simple and easy way. Send your feedback for rectification/further development.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
3. Standard Input
• Standard input refers to the input using keyboard
• A program may need certain input from the user
• C language provides many functions to get intput from the user:
• scanf()
• gets()
• getch()
• getche()
• Include the header file <stdio.h> in program to call scanf() and gets()
and include the header file <conio.h> in program to call getch() and
getche() function.
4. Standard Output
• The term standard output refers to the output displayed on the monitor
• The result of a program is called the out of the program
• C language provides many functions to display program output to the
user
• Printf()
• Puts()
• Include the header file <stdio.h> in program to call printf() and puts()
5. printf ( ) function
• The printf function is used to display output on the monitor
• It can display text, constants, values of variables or expressions on
monitor in specified format:
Syntax: printf (Format String, argument_list);
Format String Argument list
• Also called control string
• Give in double quotes
• May consist of the following:
• Text
• Format specifiers
• Escape sequence
• Consists of constants, variable
or expression are to be printed
on the screen
• Separated by comma
• Use of argument list is
optional
6. • Using Format String without Argument List
printf(“Hello World”);
Control String
• Using Format String with Single Argument
int m =80;
printf(“ Your marks are %d”, m);
Control String
• Using Format String with Multiple Arguments
int m=80;
char c=‘A’;
• Printf(“your marks are %d and grade %c”, m, c);
• One printf can print several lines by using newline escape sequence – ‘n’
printf( “ Welcome n to n C “);
Format strings can have
multiple format specifier, if
you are printing multiple
values
7.
8. Program 10.1
Write a program that displays a message and values of integer and character
variables.
#include<stdio.h>
#include<conio.h>
void main()
{
int n=10;
char ch='*';
clrscr();
printf("Testing Output...");
printf("%d",n);
printf("%c",ch);
getch();
}
9. Program 10.2
Write a program that adds two floating point numbers and shows the
sum on the screen
#include<stdio.h>
#include<conio.h>
void main()
{
float a=2.5,b=3.0,sum;
sum = a+ b;
clrscr();
printf(“%f + %f = %f ”,a,b,sum);
getch();
}
10. Program 10.3
Write a program that calculate and print area of square with given height and width
#include<stdio.h>
#include<conio.h>
void main()
{
int area,h,w;
h=2;
w=4;
area= h *w;
printf(“Area of square is %d”,area);
// printf(“ Area of square is %d when height is %d and width is %d”,area,h,w);
getch();
}
11. Format Specifier
• Format specifier is used to specify the format according to which values
will be read and display
• It determines the following things:
• Data type of Variable
• Field width
• Format of the value
• Format specifier is started with symbol %
• Different format specifiers are used with different types of variable
• Integer format specifier
• Character format specifier
• Floating Point format specifier
3 4 5 1
3 4 5 1
12. Format Specifier
• Integer Format Specifier
Format Specifier Type
%d Used for signed decimal integer value
%i Used for signed integer value
%o Used for unsigned octal value
%u Used for unsigned integer value
%x Used for unsigned hexadecimal value with lower case like a,b,c
etc.
%X Used for unsigned hexadecimal value with Upper case like A,B,C
etc.
13. Format Specifier (Cont..)
• Floating-Point Format Specifier
• Character Format Specifier
Format Specifier Type
%f Used for signed floating point value
%e Used for exponent value
%g Used for short notation value
Format Specifier Type
%c Used for character value
%s Used for strings
14. How integer values are printed in C language?
• The format specifier %d is used to display integer values in printf
functions.
• If an integer variable m contains 100 value then it can print by
following statement:
printf(“Your marks are %d”, m);
output:
Your marks are 100
15. How floating point values are printed in C
language?
• The format specifier %f is used to display floating point value in printf
function.
• If an value of float variable a is 90.55 . The following statement:
printf(“Average marks are %f”, a);
output:
Average marks are 90.550000
17. Field Width specifier for integer
• %d format specifier is used to display integer value in printf function
• A value can be written between % and d in “%d” format specified
Example
int area =25;
printf(“Area = %4d”,area);
• The value will appear right-justified and two spaces will appear before the actual
value
21. Escape Sequence
• Special characters used in format string to modify the format
of output
• Character are not displayed in the output
• Always begin with backslash “”.
• Backslash is called an escape character
22. Escape sequence Character represented
b Backspace
f Form Feed
n New Line
r Carriage return
t Tab
’ Single quote
” Double quote
xdd
ASCII code in hexadecimal notation. Each d represent
digit
ddd ASCII code in octal notation. Each d represents a digit
23. • b use to insert backspace in the output
• f (Form Feed page break)
• n (New line) – We use it to shift the cursor control to the new line
printf(
• r (Carriage Return) – We use it to position the cursor to the
beginning of the current line.
• t (Horizontal tab) – We use it to shift the cursor to a couple of spaces
to the right in the same line.
• ’ (Apostrophe or single quotation mark) – We use it to display the
single-quotation mark.
• ” (Double quotation mark) – We use it to display the double-
quotation mark.
• (Backslash) – We use it to display the backslash character.
• a (Audible bell) – A beep is generated indicating the execution of the
program to alert the user.
25. Scanf Function
• Read data from the standard input device ( Usually Keyboard) and
store it in a variable
• Requires stdio.h header file used to read input from keyboard
• Syntax
• scanf(“format string”, &variable);
28. Character Input
• Scanf function can be used for character input
• Scanf function is not suitable for all situations, specially when enter
key is not require on any input ( e.g. arrow keys in games)
• Specialized function for character input are available
• getch()
• getche()
• These functions are part of conio.h library file
29. getch()
• The getch function is used to input single character from the user
• Requires conio.h header file to use this function
• When this function is executed, it waits for any key to be pressed
• Character entered by the user is not displayed on the screen
• The function is frequently used to pause program execution
Syntax: [var =] getch();
Variable It indicates the variable in which the character is stored. The
use of variable is optional
31. getche()
• The getche() function is used to input single character from the user
• Requires conio.h header file to use this function
• When this function is executed, it waits for any key to be pressed
• Character entered by the user displayed on the screen
Syntax: [var =] getche();
Variable It indicates the variable in which the character is stored. The
use of variable is optional
33. gets() Function
• Used to input string value from the user.
• User press Enter key and string is stored variable
• The null character is automatically entered at the end of string
• Requires stdio.h header file to use this function
Syntax: gets( String_Variable );
Example printf(“Enter a string”);
gets(str);
Suppose if user input “Pakistan” then the string will stores in str as follows:
P a k i s t a n 0
34. puts() Function
• Used to display string on the screen.
• It can display a string constant or string variable
• Requires stdio.h header file to use this function
Syntax: puts( parameter );
Parameter It indicates the string variable in which the string is stored.
In case of string constant, it is written in double quotes
Example puts(str);
35. • Program 10.25
Write a program that inputs a string and displays it on a screen
#include<stdio.h>
#include<conio.h>
void main()
{
char book[ 50];
clrscr();
printf(“Enter name of your favorit book”);
gets(book);
printf(“Your favorite book is”);
puts(book);
getch();
}
Enter name of your favourite book : Holy Quran
Your favourite book is : Holy Quran
36. clrscr() Function
• Used to clear screen
• after clear the screen cursor blinks on the top-left corner
• Requires conio.h header file to use this function
Syntax: clrscr();
37. sizeof Operator
• Used to find the size of any data value
• Its give the number of bytes occupied by that value
Syntax: sizeof(operand);
Examples : sizeof(10);
sizeof(4.5);
sizeof(“Pakistan”);
sizeof(‘A’);