SlideShare a Scribd company logo
6
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Identifiers:
An identifier is a sequence of characters that represents an entity such as a
function or a data objects.
Constant:
Constant is a value that can be stored in the memory and cannot be changed
during execution of the program. C constants are given below;
Strings (alphabets):
A string is a sequence of characters. Theseare stored in memory as ASCII codes
of characters that make up the string appended with ‘0’ (scii value of null). Normally
each character is stored in one byte, successive characters are stored in successive
bytes. Any sequence or set of characters defined within double quotation symbols is
constant string.
Variables:
Variable is a named location in memory, i.e. Used to hold a value that can be
modified by the program. These variable can take different values but one at a time.
The values of variables can be changed during execution. All the variables should be
declared before they can be used. Variable names may be consists of uppercase
character, lower case character and underscore. 5bc, int, rec#, avg no etc. Are invalid
variables.
Operators:
An operator is a symbol that tells the processor to perform certain
mathematical or logical manipulations. Operators arein programs to manipulate data
and variables. The data itself is called ‘operand’. Operators thus operate on
C constant
Numeric Constants
constant
Character Constants
constant
Integer Constants
constant
Real Constants
constant
Single character
Constants constant
String constant
Most read
7
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
operands. C programming language is extremely rich in operators. It has about 45
different operators. The usually form a part of mathematical or logical series called
expressions.
Types of operators:
Depending on the functions performed, the C programming language
operators can be classified into a number of categories;
Arithmetic operators:
Arithmetical operators generally include arithmetic operands. Arithmetical
operators are given below;
+ (for addition)
- (for subtraction)
*(for multiplication)
/(for division)
%(for remainder)
These operators can work with int, float or char.
Relational operators:
Relational operators are for relational operation. These are variables,
constants or expressions. Characters are also represented internally as integers (by
their ascii codes), elements to be compared can characters as well.
= = (equal to)
!= (not equal to)
>(greater than)
<(less than)
<=(less than or equal to)
>=(greater than or equal to)
Logical operators:
By using a logical operator an expression evaluates to either true (non zero
value) or false (0).
&& (logical and)
|| (logical or)
! (logical not)
Most read
21
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
scanf(“%f”,&r);
i=)p*t*r)/100);
printf(“the simple interest is : rs. %.2f”,i);
getch();
}
Data input/output:
The mainly common library functions responsible for input and output
operations in c are; getchar(), putchar(), scanf(), printf(), gets() and puts(). The
getchar() and putchar() are the functions used to accept a single character from the
keyboard and display on the monitor. The scanf() and printf() functions are flexible.
They can accept values, characters and strings and using suitable format specifier
that can be displayed.
The getchar() function:
In this function single character can be entered into the computer using C
library function getchar(). This is a part of the standard i/o library. It returns a single
character from the standard input device (keyboard) the function does not require
any arguments but empty parentheses must follow the keyword getchar.
Character varuabke = getchar();
While using getchar() with file handling functions, if an end-of-file condition is
encountered with reading a character with the getchar function, the value of the
symbolic constant eof will automatically be returned.
Wap to input a character from the keyboard and display.
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
printf(“enter a character: “);
c=getchar()
Most read
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
C programming language:
C programming language is one of the most popular general-purpose
programming languages. It is designed and developed by Dennis Ritchie at bell
laboratories, USA, in 1972. Several important concepts of C are drawn from “Basic
Combined Programming Language” and “B” language. The BCPL was developed by
Martin Richards in 1967 and B Language was developed by Ken Thompson in 1970. C
Language is not fixed to any particular operating system. It can be used to develop
new operating systems. The C language is closely associated with the UNIX operating
system because the source code for the UNIX operating system is in C. It runs
different types of operating system like DOS, Windows etc. the C Programming
Language is highly portable because it can be written on one computer can be run on
another with simple or almost no modification
Importance of c language:
1. The C language is a robust language whose rich set of built-in functions and
operators can be used to write any complex program. The C compiler combines
the capabilities of an assembly language with the features of a high-level
language. Therefore, it is well suited for writing both system and application
packages. (robust language)
2. Programwritten in c language are efficient and fast due to its variety of data types
and powerful operators. (efficient and fast)
3. C language is highly portable, means that c program written for one computer can
be run on another computer with little or no modifications. (highly portable)
4. C language is well suited for structured programming, thus requiring the user to
think of a problem in terms of function modules or blocks. A proper collection of
these modules would make a complete program. This modular structure makes
program debugging, testing and maintenance easier and fast. (structured
language)
5. C program may contain a number of user defined functions. We can add our own
user defined functions to the c library if required. (extendibility)
6. C program is a middle level language because it combines the best part of high
level language with low level language. It is well suited for writing both user and
machine oriented programs and provides infinite possibilities. (middle level
language)
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
7. In C language, there are large numbers of built in functions, keywords and
operators in C’s
system library organized in different header files. Using built-in
functions, we can save our effort and reduce the size of the program.
The history and development of c
1960 International Group
1967 Martin Richards
1970 Ken Thompson
1972 Dennis Ritchie
1978 Kernighan and Ritchie
Elements of c programming language:
Every c programming language consists of one or more modules. These modules
are called functions. One of the functions must be called main(). The program will
always begin by executing the main function. This function may access other
functions. There can be many functions. Each function should be defined separately.
The user defined functions are either defined ahead of main function or within the
main function. Each function must contain the following;
 A function heading, which consists of the function name(including the arguments
if present)
 A list of argument declarations if the arguments are included in the heading
 A compound statement, which comprises the remainder of the function
Algorithm Language
ALGOL
BCPL
B Language
Traditional C
K & R C
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
The arguments are also called the parameters. Each compo9und statement is
enclosed within a pair of braces i.e. { }. The comments or remarks may appear
within the program anywhere within the delimiters /* and */. The comments help
to read the program and makes convenient during debugging the program errors.
Structure of a c programming:
The structure of a C program implies the composition of a program, i.e. It
answers and questions such as “what are main components to write a c program?
How are they organized?”
or
header file
void main ()
{
…………………………..
………………………….
………………………….
statements; body
………………………………..
………………………………
Include header file section
Global Declaration section
/* comments*/
intmain(void) /*functionname */
{
/* comments*/
Declarationpart
Executable part
Return0;
}
User-definedfunctions
{
Bodyof the function
}
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
……………………………….
}
C programming
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“hello, this is my first c programming”);
}
Justification:
#include directive: Itis the mostessential directive. A directive is links to a
header file. The header file makes full use of the i/o functions of the standard C
library. Here stdio.h is a header file and # sign is known as preprocessing directive.
void main(): Itis the main function that must appear in every C program. main
without void is used when there are no arguments. main() withoutany parameters
has an argument.
printf(): The printf() function is used to print out the message, either on paper or
screen. The letter f in printf function stands for formatted.
getch(): Itis defined in stdio.h header file. This function holds from screen scrolling.
Learning programming concept:
#include<stdio.h>
void main()
{
/* ………….. Printing begins ……*/
printf(“Hello, I am Chetan Thapa Magar”); /*www.facebook.com/MeIDoKoXora*/
/*……………..printing ends ………………*/
}
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Steps in learning a language:
Generally steps used in c programming are given below;
Character set:
The C character set includes alphabets of both upper (a-z) and lower case (a-z)
letters can be used in C programming language. Followings are the character set used
in C programming language.
Nature Symbols
Alphabets A-z, a-z
Numerals 0-9
Arithmetic + - * / % = ?
Logical ! < >| &
Parentheses ( ) { } [ ]
Punctuation ; : , .
Special = ‘ “ #  ^ ~ (blank)
C tokens:
In C programming language text, a word and punctuation marks are called
tokens. It is also called smallest individual keywords.
Reserved keywords in C programming language are given below;
Auto Break Case Char Const Continue Default Do
Double Else Enum Extern Float For Goto If
Int Long Register Return Short Signed Sizeof Static
Struct Switch Typedef Union Unsigned Void Volatile While
Character set C tokens Statements Programs
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Identifiers:
An identifier is a sequence of characters that represents an entity such as a
function or a data objects.
Constant:
Constant is a value that can be stored in the memory and cannot be changed
during execution of the program. C constants are given below;
Strings (alphabets):
A string is a sequence of characters. Theseare stored in memory as ASCII codes
of characters that make up the string appended with ‘0’ (scii value of null). Normally
each character is stored in one byte, successive characters are stored in successive
bytes. Any sequence or set of characters defined within double quotation symbols is
constant string.
Variables:
Variable is a named location in memory, i.e. Used to hold a value that can be
modified by the program. These variable can take different values but one at a time.
The values of variables can be changed during execution. All the variables should be
declared before they can be used. Variable names may be consists of uppercase
character, lower case character and underscore. 5bc, int, rec#, avg no etc. Are invalid
variables.
Operators:
An operator is a symbol that tells the processor to perform certain
mathematical or logical manipulations. Operators arein programs to manipulate data
and variables. The data itself is called ‘operand’. Operators thus operate on
C constant
Numeric Constants
constant
Character Constants
constant
Integer Constants
constant
Real Constants
constant
Single character
Constants constant
String constant
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
operands. C programming language is extremely rich in operators. It has about 45
different operators. The usually form a part of mathematical or logical series called
expressions.
Types of operators:
Depending on the functions performed, the C programming language
operators can be classified into a number of categories;
Arithmetic operators:
Arithmetical operators generally include arithmetic operands. Arithmetical
operators are given below;
+ (for addition)
- (for subtraction)
*(for multiplication)
/(for division)
%(for remainder)
These operators can work with int, float or char.
Relational operators:
Relational operators are for relational operation. These are variables,
constants or expressions. Characters are also represented internally as integers (by
their ascii codes), elements to be compared can characters as well.
= = (equal to)
!= (not equal to)
>(greater than)
<(less than)
<=(less than or equal to)
>=(greater than or equal to)
Logical operators:
By using a logical operator an expression evaluates to either true (non zero
value) or false (0).
&& (logical and)
|| (logical or)
! (logical not)
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Assignment operators:
Assignment operator takes the form as,
Variable = expression
The basic assignment operator is (=)
Unary operator:
A unary operator is an operator that requires only one operand. For example,
++, the increment operator, - - the decrement operator and ‘!’ logical negator.
Conditional operator:
A ternary operator pair “?:” is available in C programming to construct
conditional expressions of the form
Exp1? Exp2: exp3 (where exp1, exp2 and exp3 are conditional expressions).
Bitwise operator:
C programming language has a distinction of supporting special operators
known as bitwise operators for manipulation of data at bit level. These operators are
used for testing the bits or shifting them right or left. Bitwise operators may not be
applied to float or double.
Operator meaning
& bitwise and
| bitwise or
^ bitwise exclusive or
<< shift left
>> shift right
Decision making structures:
C programming language has various kinds of statements that permit the
execution of a single statement, or block of statement, based on the evaluation of a
test expression or permit the selection of the statement in the executed among
several statements based on the value of an expression or a control variable. C
programming language supports two selection statements; if and switch.
If-else statement:
The general syntax and flowchart of the if statement is given below;
syntax:
if(expression) IF
Condition
No Yes
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
{
Statement;
}
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Where statement may consist of a single statement, a block of statements or nothing
(in the case of empty statements). The else clause is optional.
Write a program to display odd or even number:
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf(“enter any number which is odd or even:”);
scanf(“%d”, &a);
if(a%2==0)
printf(“%d the number is even number”,a);
else
printf(“%d the number is odd number”,a);
getch();
}
Wap1
to find the sum of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, sum=0;
clrscr();
printf(“enter the value of a:”);
scanf(“%d”,&a);
printf(“enter the value of b:”);
scanf(“%d”,&b);
sum=a+b;
printf(“the sum of a and b is:%d”,sum);
getch();
}
Switch-case statement:
1 Write a Program (wap)
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
C programming language has a built-in multiple branch selection statement,
called switch, which is used to test the value of an expression against a list of integer
or character constants. When a match is found the statements associated with that
constant are executed until break or end of switch is encountered. The break
interrupts the normal flow of control and then moves to the end of the code or
resumes to the normal execution. The default statement is executed if no matches
are found. The default is optional and if it is not present no action takes place if all
matches fail.
Syntax:
switch (expression)
{
case constant1:
statement sequence
break;
case constant2:
statement sequence
break:
case constant3:
statement sequence
break;
……………………
……………………
…………………..
default
statement sequence
}
example:
#include<stdio.h>
#include<conio.h>
void main()
{
int x;
clrscr();
printf(“enter the value of xn”);
scanf(“%d”, &x);
switch(x)
{
case 1;
printf(“one”);
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
break;
case 2;
printf(“two”);
break;
case 3;
printf(“three”);
break;
case 4;
printf(“four”);
break;
default:
printf(“no value”);
}
getch();
}
Wap to find the length of the string using printf() function:
#include<stdio.h>
#include<conio.h>
void main()
{
char name[20];
char length;
clrscr();
printf(“enter the word/string :”);
scanf(“%s”,name);
length=printf(name);
printf(“nlength of a string=%d”,length);
getch();
}
Output:
Enter the word/string : chetan
Length of a string = 6
Loop control structures:
C programming language has three loop constructs, which are given below;
1) For loop
2) While loop
3) Do-while loop
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
For loop:
For loop allow a set of instructions to be repeatedly (continually) executed
until a certain condition is reached. This condition may be predetermined (fixed) or
open ended.
Syntax:
for(initialization; condition; increment or decrement)
{
statement;
}
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b
a=5;
b=15;
clrscr();
if(a<b)
{
printf(“a is smaller than b”);
}
else if(a>b)
{
printf(“a is greater than b”);
}
getch();
}
Wap to find the smallest out of the three numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c, smallest;
clrscr();
printf(“nenter the three numbers : “);
scanf(“%d %d %d”, &a, &b, &c);
if(a<b)
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
{
if(a<c)smallest =;
else
smallest = c;
}
else
{
if(b<c)
smallest =b;
else
smallest = c;
}
printf)”the smallest of %d %d %d is %dn”,a,b,c,smallest);
getch();
}
Example for (for loop)
Wap to display the multiplication table 1-12
#include<stdio.h>
#include<conio.h>
void main()
{
int row, column;
puts(“t multiplication table 1-12”);
for(row=1;row<=10;row++)
{
for(column=1;column<=12;column++)
printf(“%5d”,row*column);
putchar(‘n’);
}
getch();
}
While loop:
In C programming language while loop is used to check the test condition at
the top of the loop, which means that the body of the loop will not execute if the
condition is false to begin with. This feature may eliminate (remove) the need to
perform a separate conditional test before the loop.
Syntax:
while (condition)
{
statements;
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
}
Do-while loop:
In C programming language the do-while loop checks its condition at the
bottom of the loop. This means that a do-while loop always execute at least once.
The general form of the do-while loop is given below;
Syntax:
do
{
statement;
}
while (condition);
Break statement:
Break is a simple statement. It only makes sense if it occurs in the body of a
switch, do, while or for statement. When it is executed the control of flow jumps to
the statement immediately.
Exit statement:
exit() is a function. It is used to exit the program as a whole. In other words it
returns control to the operating system.
Difference between break and exit statement:
1. break is a keyword 1. exit is a function
2. No header file is needed 2.header file process.h must be needed
3. break stops the execution 3. It terminates the program.
Of the loop.
Wap that reads the marks of a student in 7 subjects. Then calculate the
percentage and determine the division using following conditions.
%>=80 distinction
%between 60 and 79 first division
%between 45 and 59 second division
%between 32 and 44 third division
%<=31 fail
#include<stdio.h>
#include<conio.h>
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
void main()
{
float nep, eng, math, phy, chem, bio, comp, percent;
printf(“enter the marks in nepali:”);
scanf(“%f”,&nep);
printf(“enter the marks in english:”);
scanf(“%f”,&eng);
printf(“enter the marks in math:”);
scanf(“%f”,&math);
printf(“enter the marks in physics:”);
scanf(“%f”,&phy);
printf(“enter the marks in chemistry:”);
scanf(“%f”,&chem);
printf(“enter the marks in biology:”);
scanf(“%f”,&bio);
printf(“enter the marks in computer:”);
scanf(“%f”,&comp);
percent = (nep + eng + math + phy + chem + bio + comp) /7;
if(percent>=80)
printf(“your division is : distinction”);
else
if(percent>=60 && percent<80)
printf(“your division is : first division”);
else
if(percent>=40 && percent<60)
printf(“your division is : second division”);
else
if(percent>=32 && percent<45)
printf(“your division is : third disivion”);
else
printf(“sorry you are : fail”);
printf(“nyour percentage is %2f”,percent);
getch();
}
Wap to display the message “universal computer institute”15 times using for loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<15;i++)
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
printf(“nuniversal computer institute”);
getch();
}
Wap to display the table of 2 using while loop
#include<stdio.h>
#include<conio.h>
void main()
{
int a=2.i=1,b;
clrscr();
while(i<=10)
{
b=a * i;
printf(“2*%d=%dn”,i,b);
i++;
}
getch();
}
Wap to display the table of 2 using do-while loop
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,b;
clrscr();
do
{
b=2*i;
i++;
printf(“%dn”,b);
i++;
}
while(i<=10);
getch();
}
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
Nested loop:
When the body part of the loop contains another loop then the inner loop is
said to be nested within the outer loop. Since a loop may contain other loops within
its body, there is no limit of the number of loops that can be nested. In the case of
nested loop, for each value or pass of outer loop, inner loop is completely executed.
Thus, inner loop operates/moves fast and outer loop operates slowly. Or loop within
the loop is known as nested loop.
For example, we can write syntax of nested for loops as;
for(counter initialization; test condition;increment/decrement)
{
for (counter initialization;test;incr/decr)
{
statements;
}
}
Wap to display multiplication table 1-10
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=2;i<=10;i++)
for(j=1;j<=10;j++)
{
printf(“%d*%d=%dt”,i,j,i*j);
}
printf(“n”);
}
getch();
)
Wap to display the following pattern
*
* *
* * *
Outer
loop
Inner
loop
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
* * * *
* * * * *
* * * * * *
* * * * * * *
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j;
clrscr();
for(i=1;i<=7;i++)
{
for(j=1;j<=i;j++)
{
printf(“*”);
}
printf(“n”);
}
getch();
}
Special characters:
, (comma) & (ampersand)
. (period) ^ (caret)
; (semicolon) * (asterisk)
: (colon) - (minus sign)
? (question mark) + (plus sign)
‘ (apostrophe) < (less than sign)
“ (quotation mark) > (greater than sign)
! (exclamation mark) | (vertical bar)
/ (forward slash)  (backward slash)
~ (tilde sign) _ (underscore)
$ (dollar sign) % (percent sign)
( (left parenthesis) ) (right parenthesis)
[ (left bracket) ] (right bracket)
{ (left brace) } (right brace)
# (number sing/) hash
Data types:
There are four types of data type;
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
int : This type of data type is used to store the integer value.
char: This type of data type is used to store any single character.
float : This type of data type is used to store decimal numbers.
double: This type of data type is store long range of decimal numbers.
Wap that ask the name of student and marks obtained by him/her in
given subjects. Display the percentage of the student assuming full mark
100 for each subject.
#include<stdio.h>
#include<conio.h>
int main()
{
char name[15];
float nep,eng,phy,chem.,soc,pop,eco,total,pct;
clrscr();
printf(“enter the name of student: “);
scanf(“%s”,name);
printf(“enter marks in seven subject: “);
scanf(“%f%f%f%f%f%f%f”,&nep,&eng,&phy,&chem.,&soc,&pop,&eco);
total=nep+eng+phy+chem+soc+pop+eco;
pct=total/7;
printf(“nthe percentage of %s is : %.2f”,name,pct);
getch();
}
Note:
The statement char name[15]; declares a string variable name which stores
collection of characters (i.e. String is array of characters).
Wap to calculate simple interest when principal, time and rate are given by the
user.
#include<stdio.h>
#include<conio.h>
void main()
{
float p,t,r,i;
clrscr();
printf(“enter principal in rs :”);
scanf(“%f”,&p);
printf(“enter time in year :”);
scanf(“%f”,&t);
printf(“enter rate in percent per anum :”);
C Programming Language
Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College )
www.facebook.comMeIDoKoXora
scanf(“%f”,&r);
i=)p*t*r)/100);
printf(“the simple interest is : rs. %.2f”,i);
getch();
}
Data input/output:
The mainly common library functions responsible for input and output
operations in c are; getchar(), putchar(), scanf(), printf(), gets() and puts(). The
getchar() and putchar() are the functions used to accept a single character from the
keyboard and display on the monitor. The scanf() and printf() functions are flexible.
They can accept values, characters and strings and using suitable format specifier
that can be displayed.
The getchar() function:
In this function single character can be entered into the computer using C
library function getchar(). This is a part of the standard i/o library. It returns a single
character from the standard input device (keyboard) the function does not require
any arguments but empty parentheses must follow the keyword getchar.
Character varuabke = getchar();
While using getchar() with file handling functions, if an end-of-file condition is
encountered with reading a character with the getchar function, the value of the
symbolic constant eof will automatically be returned.
Wap to input a character from the keyboard and display.
#include<stdio.h>
#include<conio.h>
void main()
{
char c;
printf(“enter a character: “);
c=getchar()

More Related Content

What's hot (20)

Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
C Language
C LanguageC Language
C Language
Aakash Singh
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Features of 'c' program
Features of 'c' programFeatures of 'c' program
Features of 'c' program
veer patel
 
C presentation
C presentationC presentation
C presentation
APSMIND TECHNOLOGY PVT LTD.
 
Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
Prof. Dr. K. Adisesha
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptxC-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
SKUP1
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
Harish Kumawat
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
David Livingston J
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
gourav kottawar
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
Ideal Eyes Business College
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
kash95
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
Appili Vamsi Krishna
 
Learn C
Learn CLearn C
Learn C
kantila
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
Mansi Tyagi
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Features of 'c' program
Features of 'c' programFeatures of 'c' program
Features of 'c' program
veer patel
 
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptxC-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
SKUP1
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
Harish Kumawat
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
gourav kottawar
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Storage class in c
Storage class in cStorage class in c
Storage class in c
kash95
 
User defined functions in C programmig
User defined functions in C programmigUser defined functions in C programmig
User defined functions in C programmig
Appili Vamsi Krishna
 

Viewers also liked (12)

Erica C. Sutherlin Resumes
Erica C. Sutherlin ResumesErica C. Sutherlin Resumes
Erica C. Sutherlin Resumes
Erica Sutherlin
 
MikeHallMarch2016
MikeHallMarch2016MikeHallMarch2016
MikeHallMarch2016
Mike Hall
 
Programming in c
Programming in cProgramming in c
Programming in c
ankitjain851
 
CV Juhani Polvi
CV Juhani PolviCV Juhani Polvi
CV Juhani Polvi
Juhani Polvi
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
Saket Pathak
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
C programming project by navin thapa
C programming project by navin thapaC programming project by navin thapa
C programming project by navin thapa
Navinthp
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
dharmenderlodhi021
 
Ryan jarrell resume
Ryan jarrell resumeRyan jarrell resume
Ryan jarrell resume
Ryan Jarrell
 
Compilation of previous board examination questions
Compilation of previous board examination questionsCompilation of previous board examination questions
Compilation of previous board examination questions
Rhem Rick Corpuz
 
Web developer / Full Stack Engineer/ backend Developer /Frontend Developer
Web developer / Full Stack Engineer/ backend Developer /Frontend DeveloperWeb developer / Full Stack Engineer/ backend Developer /Frontend Developer
Web developer / Full Stack Engineer/ backend Developer /Frontend Developer
ruochen Liao
 
Mcq 1060 questions
Mcq 1060 questionsMcq 1060 questions
Mcq 1060 questions
adrioz
 
Erica C. Sutherlin Resumes
Erica C. Sutherlin ResumesErica C. Sutherlin Resumes
Erica C. Sutherlin Resumes
Erica Sutherlin
 
MikeHallMarch2016
MikeHallMarch2016MikeHallMarch2016
MikeHallMarch2016
Mike Hall
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
Saket Pathak
 
C programming project by navin thapa
C programming project by navin thapaC programming project by navin thapa
C programming project by navin thapa
Navinthp
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
dharmenderlodhi021
 
Ryan jarrell resume
Ryan jarrell resumeRyan jarrell resume
Ryan jarrell resume
Ryan Jarrell
 
Compilation of previous board examination questions
Compilation of previous board examination questionsCompilation of previous board examination questions
Compilation of previous board examination questions
Rhem Rick Corpuz
 
Web developer / Full Stack Engineer/ backend Developer /Frontend Developer
Web developer / Full Stack Engineer/ backend Developer /Frontend DeveloperWeb developer / Full Stack Engineer/ backend Developer /Frontend Developer
Web developer / Full Stack Engineer/ backend Developer /Frontend Developer
ruochen Liao
 
Mcq 1060 questions
Mcq 1060 questionsMcq 1060 questions
Mcq 1060 questions
adrioz
 
Ad

Similar to C programming language Reference Note (20)

Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 
C programming course material
C programming course materialC programming course material
C programming course material
Ranjitha Murthy
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
aaravSingh41
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
muniryaseen
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
Batra Centre
 
C programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakilC programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakil
Zenith SVG
 
Programming in C and Decision Making Branching
Programming in C and Decision Making BranchingProgramming in C and Decision Making Branching
Programming in C and Decision Making Branching
Rvishnupriya2
 
Programming in C & Decision Making Branching
Programming in C & Decision Making BranchingProgramming in C & Decision Making Branching
Programming in C & Decision Making Branching
VishnuPriya810389
 
C programme presentation
C programme presentationC programme presentation
C programme presentation
DharmaKumariBhandari
 
C programming
C programming C programming
C programming
Rohan Gajre
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptx
SanketShah544615
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
C program
C programC program
C program
Shaik JaniBasha
 
C programing for BCA Sem 1. JJ College
C programing for BCA Sem 1. JJ CollegeC programing for BCA Sem 1. JJ College
C programing for BCA Sem 1. JJ College
MUNNAKUMAR89
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c language
Student
 
[email protected]_.pdf
TCS-NQT-Coding-Questions-@-Recruitmentindia.in_.pdfTCS-NQT-Coding-Questions-@-Recruitmentindia.in_.pdf
[email protected]_.pdf
AbhishekMGowda4
 
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshuunit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
GauravRawat830030
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
sumitbardhan
 
C class basic programming 1 PPT mayanka (1).pdf
C class basic programming 1 PPT mayanka (1).pdfC class basic programming 1 PPT mayanka (1).pdf
C class basic programming 1 PPT mayanka (1).pdf
mayankamandal
 
C Language ppt create by Anand & Sager.pptx
C Language ppt create by Anand & Sager.pptxC Language ppt create by Anand & Sager.pptx
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 
C programming course material
C programming course materialC programming course material
C programming course material
Ranjitha Murthy
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
aaravSingh41
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
muniryaseen
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
Batra Centre
 
C programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakilC programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakil
Zenith SVG
 
Programming in C and Decision Making Branching
Programming in C and Decision Making BranchingProgramming in C and Decision Making Branching
Programming in C and Decision Making Branching
Rvishnupriya2
 
Programming in C & Decision Making Branching
Programming in C & Decision Making BranchingProgramming in C & Decision Making Branching
Programming in C & Decision Making Branching
VishnuPriya810389
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptx
SanketShah544615
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
Mugilvannan11
 
C programing for BCA Sem 1. JJ College
C programing for BCA Sem 1. JJ CollegeC programing for BCA Sem 1. JJ College
C programing for BCA Sem 1. JJ College
MUNNAKUMAR89
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c language
Student
 
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshuunit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
unit 1 programming in c ztgdawte efhgfhj ewnfbshyufh fsfyshu
GauravRawat830030
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
sumitbardhan
 
C class basic programming 1 PPT mayanka (1).pdf
C class basic programming 1 PPT mayanka (1).pdfC class basic programming 1 PPT mayanka (1).pdf
C class basic programming 1 PPT mayanka (1).pdf
mayankamandal
 
C Language ppt create by Anand & Sager.pptx
C Language ppt create by Anand & Sager.pptxC Language ppt create by Anand & Sager.pptx
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
Ad

Recently uploaded (20)

SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Vikas Bansal Himachal Pradesh: A Visionary Transforming Himachal’s Educationa...
Himalayan Group of Professional Institutions (HGPI)
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobediencePaper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo SlidesOverview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptxChalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
Revista digital preescolar en transformación
Revista digital preescolar en transformaciónRevista digital preescolar en transformación
Revista digital preescolar en transformación
guerragallardo26
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil DisobediencePaper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptxROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptxCapitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo SlidesOverview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke WarnerPublishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 

C programming language Reference Note

  • 1. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora C programming language: C programming language is one of the most popular general-purpose programming languages. It is designed and developed by Dennis Ritchie at bell laboratories, USA, in 1972. Several important concepts of C are drawn from “Basic Combined Programming Language” and “B” language. The BCPL was developed by Martin Richards in 1967 and B Language was developed by Ken Thompson in 1970. C Language is not fixed to any particular operating system. It can be used to develop new operating systems. The C language is closely associated with the UNIX operating system because the source code for the UNIX operating system is in C. It runs different types of operating system like DOS, Windows etc. the C Programming Language is highly portable because it can be written on one computer can be run on another with simple or almost no modification Importance of c language: 1. The C language is a robust language whose rich set of built-in functions and operators can be used to write any complex program. The C compiler combines the capabilities of an assembly language with the features of a high-level language. Therefore, it is well suited for writing both system and application packages. (robust language) 2. Programwritten in c language are efficient and fast due to its variety of data types and powerful operators. (efficient and fast) 3. C language is highly portable, means that c program written for one computer can be run on another computer with little or no modifications. (highly portable) 4. C language is well suited for structured programming, thus requiring the user to think of a problem in terms of function modules or blocks. A proper collection of these modules would make a complete program. This modular structure makes program debugging, testing and maintenance easier and fast. (structured language) 5. C program may contain a number of user defined functions. We can add our own user defined functions to the c library if required. (extendibility) 6. C program is a middle level language because it combines the best part of high level language with low level language. It is well suited for writing both user and machine oriented programs and provides infinite possibilities. (middle level language)
  • 2. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora 7. In C language, there are large numbers of built in functions, keywords and operators in C’s system library organized in different header files. Using built-in functions, we can save our effort and reduce the size of the program. The history and development of c 1960 International Group 1967 Martin Richards 1970 Ken Thompson 1972 Dennis Ritchie 1978 Kernighan and Ritchie Elements of c programming language: Every c programming language consists of one or more modules. These modules are called functions. One of the functions must be called main(). The program will always begin by executing the main function. This function may access other functions. There can be many functions. Each function should be defined separately. The user defined functions are either defined ahead of main function or within the main function. Each function must contain the following;  A function heading, which consists of the function name(including the arguments if present)  A list of argument declarations if the arguments are included in the heading  A compound statement, which comprises the remainder of the function Algorithm Language ALGOL BCPL B Language Traditional C K & R C
  • 3. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora The arguments are also called the parameters. Each compo9und statement is enclosed within a pair of braces i.e. { }. The comments or remarks may appear within the program anywhere within the delimiters /* and */. The comments help to read the program and makes convenient during debugging the program errors. Structure of a c programming: The structure of a C program implies the composition of a program, i.e. It answers and questions such as “what are main components to write a c program? How are they organized?” or header file void main () { ………………………….. …………………………. …………………………. statements; body ……………………………….. ……………………………… Include header file section Global Declaration section /* comments*/ intmain(void) /*functionname */ { /* comments*/ Declarationpart Executable part Return0; } User-definedfunctions { Bodyof the function }
  • 4. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora ………………………………. } C programming #include<stdio.h> #include<conio.h> void main() { printf(“hello, this is my first c programming”); } Justification: #include directive: Itis the mostessential directive. A directive is links to a header file. The header file makes full use of the i/o functions of the standard C library. Here stdio.h is a header file and # sign is known as preprocessing directive. void main(): Itis the main function that must appear in every C program. main without void is used when there are no arguments. main() withoutany parameters has an argument. printf(): The printf() function is used to print out the message, either on paper or screen. The letter f in printf function stands for formatted. getch(): Itis defined in stdio.h header file. This function holds from screen scrolling. Learning programming concept: #include<stdio.h> void main() { /* ………….. Printing begins ……*/ printf(“Hello, I am Chetan Thapa Magar”); /*www.facebook.com/MeIDoKoXora*/ /*……………..printing ends ………………*/ }
  • 5. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora Steps in learning a language: Generally steps used in c programming are given below; Character set: The C character set includes alphabets of both upper (a-z) and lower case (a-z) letters can be used in C programming language. Followings are the character set used in C programming language. Nature Symbols Alphabets A-z, a-z Numerals 0-9 Arithmetic + - * / % = ? Logical ! < >| & Parentheses ( ) { } [ ] Punctuation ; : , . Special = ‘ “ # ^ ~ (blank) C tokens: In C programming language text, a word and punctuation marks are called tokens. It is also called smallest individual keywords. Reserved keywords in C programming language are given below; Auto Break Case Char Const Continue Default Do Double Else Enum Extern Float For Goto If Int Long Register Return Short Signed Sizeof Static Struct Switch Typedef Union Unsigned Void Volatile While Character set C tokens Statements Programs
  • 6. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora Identifiers: An identifier is a sequence of characters that represents an entity such as a function or a data objects. Constant: Constant is a value that can be stored in the memory and cannot be changed during execution of the program. C constants are given below; Strings (alphabets): A string is a sequence of characters. Theseare stored in memory as ASCII codes of characters that make up the string appended with ‘0’ (scii value of null). Normally each character is stored in one byte, successive characters are stored in successive bytes. Any sequence or set of characters defined within double quotation symbols is constant string. Variables: Variable is a named location in memory, i.e. Used to hold a value that can be modified by the program. These variable can take different values but one at a time. The values of variables can be changed during execution. All the variables should be declared before they can be used. Variable names may be consists of uppercase character, lower case character and underscore. 5bc, int, rec#, avg no etc. Are invalid variables. Operators: An operator is a symbol that tells the processor to perform certain mathematical or logical manipulations. Operators arein programs to manipulate data and variables. The data itself is called ‘operand’. Operators thus operate on C constant Numeric Constants constant Character Constants constant Integer Constants constant Real Constants constant Single character Constants constant String constant
  • 7. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora operands. C programming language is extremely rich in operators. It has about 45 different operators. The usually form a part of mathematical or logical series called expressions. Types of operators: Depending on the functions performed, the C programming language operators can be classified into a number of categories; Arithmetic operators: Arithmetical operators generally include arithmetic operands. Arithmetical operators are given below; + (for addition) - (for subtraction) *(for multiplication) /(for division) %(for remainder) These operators can work with int, float or char. Relational operators: Relational operators are for relational operation. These are variables, constants or expressions. Characters are also represented internally as integers (by their ascii codes), elements to be compared can characters as well. = = (equal to) != (not equal to) >(greater than) <(less than) <=(less than or equal to) >=(greater than or equal to) Logical operators: By using a logical operator an expression evaluates to either true (non zero value) or false (0). && (logical and) || (logical or) ! (logical not)
  • 8. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora Assignment operators: Assignment operator takes the form as, Variable = expression The basic assignment operator is (=) Unary operator: A unary operator is an operator that requires only one operand. For example, ++, the increment operator, - - the decrement operator and ‘!’ logical negator. Conditional operator: A ternary operator pair “?:” is available in C programming to construct conditional expressions of the form Exp1? Exp2: exp3 (where exp1, exp2 and exp3 are conditional expressions). Bitwise operator: C programming language has a distinction of supporting special operators known as bitwise operators for manipulation of data at bit level. These operators are used for testing the bits or shifting them right or left. Bitwise operators may not be applied to float or double. Operator meaning & bitwise and | bitwise or ^ bitwise exclusive or << shift left >> shift right Decision making structures: C programming language has various kinds of statements that permit the execution of a single statement, or block of statement, based on the evaluation of a test expression or permit the selection of the statement in the executed among several statements based on the value of an expression or a control variable. C programming language supports two selection statements; if and switch. If-else statement: The general syntax and flowchart of the if statement is given below; syntax: if(expression) IF Condition No Yes
  • 9. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora { Statement; }
  • 10. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora Where statement may consist of a single statement, a block of statements or nothing (in the case of empty statements). The else clause is optional. Write a program to display odd or even number: #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf(“enter any number which is odd or even:”); scanf(“%d”, &a); if(a%2==0) printf(“%d the number is even number”,a); else printf(“%d the number is odd number”,a); getch(); } Wap1 to find the sum of two numbers #include<stdio.h> #include<conio.h> void main() { int a, b, sum=0; clrscr(); printf(“enter the value of a:”); scanf(“%d”,&a); printf(“enter the value of b:”); scanf(“%d”,&b); sum=a+b; printf(“the sum of a and b is:%d”,sum); getch(); } Switch-case statement: 1 Write a Program (wap)
  • 11. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora C programming language has a built-in multiple branch selection statement, called switch, which is used to test the value of an expression against a list of integer or character constants. When a match is found the statements associated with that constant are executed until break or end of switch is encountered. The break interrupts the normal flow of control and then moves to the end of the code or resumes to the normal execution. The default statement is executed if no matches are found. The default is optional and if it is not present no action takes place if all matches fail. Syntax: switch (expression) { case constant1: statement sequence break; case constant2: statement sequence break: case constant3: statement sequence break; …………………… …………………… ………………….. default statement sequence } example: #include<stdio.h> #include<conio.h> void main() { int x; clrscr(); printf(“enter the value of xn”); scanf(“%d”, &x); switch(x) { case 1; printf(“one”);
  • 12. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora break; case 2; printf(“two”); break; case 3; printf(“three”); break; case 4; printf(“four”); break; default: printf(“no value”); } getch(); } Wap to find the length of the string using printf() function: #include<stdio.h> #include<conio.h> void main() { char name[20]; char length; clrscr(); printf(“enter the word/string :”); scanf(“%s”,name); length=printf(name); printf(“nlength of a string=%d”,length); getch(); } Output: Enter the word/string : chetan Length of a string = 6 Loop control structures: C programming language has three loop constructs, which are given below; 1) For loop 2) While loop 3) Do-while loop
  • 13. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora For loop: For loop allow a set of instructions to be repeatedly (continually) executed until a certain condition is reached. This condition may be predetermined (fixed) or open ended. Syntax: for(initialization; condition; increment or decrement) { statement; } Example: #include<stdio.h> #include<conio.h> void main() { int a,b a=5; b=15; clrscr(); if(a<b) { printf(“a is smaller than b”); } else if(a>b) { printf(“a is greater than b”); } getch(); } Wap to find the smallest out of the three numbers #include<stdio.h> #include<conio.h> void main() { int a,b,c, smallest; clrscr(); printf(“nenter the three numbers : “); scanf(“%d %d %d”, &a, &b, &c); if(a<b)
  • 14. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora { if(a<c)smallest =; else smallest = c; } else { if(b<c) smallest =b; else smallest = c; } printf)”the smallest of %d %d %d is %dn”,a,b,c,smallest); getch(); } Example for (for loop) Wap to display the multiplication table 1-12 #include<stdio.h> #include<conio.h> void main() { int row, column; puts(“t multiplication table 1-12”); for(row=1;row<=10;row++) { for(column=1;column<=12;column++) printf(“%5d”,row*column); putchar(‘n’); } getch(); } While loop: In C programming language while loop is used to check the test condition at the top of the loop, which means that the body of the loop will not execute if the condition is false to begin with. This feature may eliminate (remove) the need to perform a separate conditional test before the loop. Syntax: while (condition) { statements;
  • 15. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora } Do-while loop: In C programming language the do-while loop checks its condition at the bottom of the loop. This means that a do-while loop always execute at least once. The general form of the do-while loop is given below; Syntax: do { statement; } while (condition); Break statement: Break is a simple statement. It only makes sense if it occurs in the body of a switch, do, while or for statement. When it is executed the control of flow jumps to the statement immediately. Exit statement: exit() is a function. It is used to exit the program as a whole. In other words it returns control to the operating system. Difference between break and exit statement: 1. break is a keyword 1. exit is a function 2. No header file is needed 2.header file process.h must be needed 3. break stops the execution 3. It terminates the program. Of the loop. Wap that reads the marks of a student in 7 subjects. Then calculate the percentage and determine the division using following conditions. %>=80 distinction %between 60 and 79 first division %between 45 and 59 second division %between 32 and 44 third division %<=31 fail #include<stdio.h> #include<conio.h>
  • 16. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora void main() { float nep, eng, math, phy, chem, bio, comp, percent; printf(“enter the marks in nepali:”); scanf(“%f”,&nep); printf(“enter the marks in english:”); scanf(“%f”,&eng); printf(“enter the marks in math:”); scanf(“%f”,&math); printf(“enter the marks in physics:”); scanf(“%f”,&phy); printf(“enter the marks in chemistry:”); scanf(“%f”,&chem); printf(“enter the marks in biology:”); scanf(“%f”,&bio); printf(“enter the marks in computer:”); scanf(“%f”,&comp); percent = (nep + eng + math + phy + chem + bio + comp) /7; if(percent>=80) printf(“your division is : distinction”); else if(percent>=60 && percent<80) printf(“your division is : first division”); else if(percent>=40 && percent<60) printf(“your division is : second division”); else if(percent>=32 && percent<45) printf(“your division is : third disivion”); else printf(“sorry you are : fail”); printf(“nyour percentage is %2f”,percent); getch(); } Wap to display the message “universal computer institute”15 times using for loop. #include<stdio.h> #include<conio.h> void main() { int i; clrscr(); for(i=0;i<15;i++)
  • 17. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora printf(“nuniversal computer institute”); getch(); } Wap to display the table of 2 using while loop #include<stdio.h> #include<conio.h> void main() { int a=2.i=1,b; clrscr(); while(i<=10) { b=a * i; printf(“2*%d=%dn”,i,b); i++; } getch(); } Wap to display the table of 2 using do-while loop #include<stdio.h> #include<conio.h> void main() { int i=1,b; clrscr(); do { b=2*i; i++; printf(“%dn”,b); i++; } while(i<=10); getch(); }
  • 18. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora Nested loop: When the body part of the loop contains another loop then the inner loop is said to be nested within the outer loop. Since a loop may contain other loops within its body, there is no limit of the number of loops that can be nested. In the case of nested loop, for each value or pass of outer loop, inner loop is completely executed. Thus, inner loop operates/moves fast and outer loop operates slowly. Or loop within the loop is known as nested loop. For example, we can write syntax of nested for loops as; for(counter initialization; test condition;increment/decrement) { for (counter initialization;test;incr/decr) { statements; } } Wap to display multiplication table 1-10 #include<stdio.h> #include<conio.h> void main() { int i,j; clrscr(); for(i=2;i<=10;i++) for(j=1;j<=10;j++) { printf(“%d*%d=%dt”,i,j,i*j); } printf(“n”); } getch(); ) Wap to display the following pattern * * * * * * Outer loop Inner loop
  • 19. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora * * * * * * * * * * * * * * * * * * * * * * #include<stdio.h> #include<conio.h> void main() { int i, j; clrscr(); for(i=1;i<=7;i++) { for(j=1;j<=i;j++) { printf(“*”); } printf(“n”); } getch(); } Special characters: , (comma) & (ampersand) . (period) ^ (caret) ; (semicolon) * (asterisk) : (colon) - (minus sign) ? (question mark) + (plus sign) ‘ (apostrophe) < (less than sign) “ (quotation mark) > (greater than sign) ! (exclamation mark) | (vertical bar) / (forward slash) (backward slash) ~ (tilde sign) _ (underscore) $ (dollar sign) % (percent sign) ( (left parenthesis) ) (right parenthesis) [ (left bracket) ] (right bracket) { (left brace) } (right brace) # (number sing/) hash Data types: There are four types of data type;
  • 20. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora int : This type of data type is used to store the integer value. char: This type of data type is used to store any single character. float : This type of data type is used to store decimal numbers. double: This type of data type is store long range of decimal numbers. Wap that ask the name of student and marks obtained by him/her in given subjects. Display the percentage of the student assuming full mark 100 for each subject. #include<stdio.h> #include<conio.h> int main() { char name[15]; float nep,eng,phy,chem.,soc,pop,eco,total,pct; clrscr(); printf(“enter the name of student: “); scanf(“%s”,name); printf(“enter marks in seven subject: “); scanf(“%f%f%f%f%f%f%f”,&nep,&eng,&phy,&chem.,&soc,&pop,&eco); total=nep+eng+phy+chem+soc+pop+eco; pct=total/7; printf(“nthe percentage of %s is : %.2f”,name,pct); getch(); } Note: The statement char name[15]; declares a string variable name which stores collection of characters (i.e. String is array of characters). Wap to calculate simple interest when principal, time and rate are given by the user. #include<stdio.h> #include<conio.h> void main() { float p,t,r,i; clrscr(); printf(“enter principal in rs :”); scanf(“%f”,&p); printf(“enter time in year :”); scanf(“%f”,&t); printf(“enter rate in percent per anum :”);
  • 21. C Programming Language Prepared By: Chetan Thapa Magar ( Brightland Higher Secondary College ) www.facebook.comMeIDoKoXora scanf(“%f”,&r); i=)p*t*r)/100); printf(“the simple interest is : rs. %.2f”,i); getch(); } Data input/output: The mainly common library functions responsible for input and output operations in c are; getchar(), putchar(), scanf(), printf(), gets() and puts(). The getchar() and putchar() are the functions used to accept a single character from the keyboard and display on the monitor. The scanf() and printf() functions are flexible. They can accept values, characters and strings and using suitable format specifier that can be displayed. The getchar() function: In this function single character can be entered into the computer using C library function getchar(). This is a part of the standard i/o library. It returns a single character from the standard input device (keyboard) the function does not require any arguments but empty parentheses must follow the keyword getchar. Character varuabke = getchar(); While using getchar() with file handling functions, if an end-of-file condition is encountered with reading a character with the getchar function, the value of the symbolic constant eof will automatically be returned. Wap to input a character from the keyboard and display. #include<stdio.h> #include<conio.h> void main() { char c; printf(“enter a character: “); c=getchar()