Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Fundamentals of Computer and programming in C
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
Structure of a C program
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
Data Types.
Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C-Language Keywords(C99)
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.Semantic © In this session we will.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Types of C Variables:  The following are some types of C variables on the basis of constants values it has. For example: ○ An integer variable can hold.
Gator Engineering 1 Chapter 2 C Fundamentals (Continued) Copyright © 2008 W. W. Norton & Company. All rights reserved.
Chapter2 Constants, Variables, and Data Types. 2.1 Introduction In this chapter, we will discuss –constants (integer, real, character, string, enum),symbolic.
C++ Basics Programming. COMP104 Lecture 5 / Slide 2 Introduction to C++ l C is a programming language developed in the 1970s with the UNIX operating system.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
C++ Lesson 1.
Variables, Identifiers, Assignments, Input/Output
Basics (Variables, Assignments, I/O)
Data types Data types Basic types
BASIC ELEMENTS OF A COMPUTER PROGRAM
LESSON 3 IO, Variables and Operators
Introduction to C Programming Language
CMSC 104, Section 4 Richard Chang
CSE101-Lec#3 Components of C Identifiers and Keywords Data types.
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CMSC 104, Section 4 Richard Chang
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Basics (Variables, Assignments, I/O)
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
C++ Basics.
פרטים נוספים בסילבוס של הקורס
Variables in C Topics Naming Variables Declaring Variables
Basics of ‘C’.
C AS A LANGUAGE Interface between computer & human being. ALPHABETS
Govt. Polytechnic,Dhangar
Variables, Identifiers, Assignments, Input/Output
Variables in C Topics Naming Variables Declaring Variables
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Variables in C Declaring , Naming, and Using Variables.
Chapter # 2 Part 2 Programs And data
Chapter 2: Introduction to C++.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
Variables in C Topics Naming Variables Declaring Variables
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
C Language B. DHIVYA 17PCA140 II MCA.
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology

C Tokens

Float while Key word Real Unreal constant

Identifier MainAmount String NameAge

Brace Curly Special Symbol Plus Minus Operators

Keywords It has 32 keywords. 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

#include void main() { char yn; clrscr(); do { puts("enter y/n(yes/no)"); yn=getchar(); fflush(stdin); if(yn!='y'&&yn!='n') puts("invalid input"); } while(yn!='y'&&yn!='n'); getch();

Constants  A constant is an entity that doesn't change during the execution of a program.  Followings are the different types of constants. 1)Real constant 2)Integer Constant 3)Character Constant 4)String Constant

1. Real Constant : It must have at least one digit. It must have a decimal point which may be positive or negative. Use of blank space and comma is not allowed between real constants. Example: ,

Real Constant It must have at least one digit. It must have a decimal point which may be positive or negative. Use of blank space and comma is not allowed between real constants. Example: ,

Integer Constant It must have at least one digit. It should not contain a decimal place. It can be positive or negative. Use of blank space and comma is not allowed between real constants. Example: 1990, 194, -394

Character Constant It is a single alphabet or a digit or a special symbol enclosed in a single quote. Maximum length of a character constant is 1. Example: 'T', '9', '$'

String Constant It is collection of characters enclosed in double quotes. It may contain letters, digits, special characters and blank space. Example: “I love Deaf“ “ All Deaf Educational Technology”

Identifier An identifier is used for any variable, function, data definition, etc. In the C programming language, an identifier is a combination of alphanumeric characters. An underline and the remaining being any letter of the alphabet, any numeric digit, or the underline.

String Strings in C are represented by arrays of characters. The end of the string is marked with a special character, the null character, which is simply the character with the value 0. The null character has no relation except in name to the null pointer. char string[15] = "Hello world!";

Sample code Program #include void main() { char in_str[21]; clrscr(); puts("Enter a string to a maximum of 20 characters"); getch(); } output Enter a string to a maximum of 20 characters Youth

Variables It is date name used date value called by valuables. It is a data name which is used to store data and may change during program execution. It is opposite to constant.

Variable name is a name given to memory cells location of a computer where data is stored. Syntax: {data types}{Variables name} =[value]

Sample code Program Example: Int count index; Float area price; Chal class types; Example of main program:- Main { Int a,b,c,=10; Char x; Float num;

Types of variables Local variable Global variable

Local variables These variables only exist inside the specific function that creates them. They are unknown to other functions and to the main program. As such, they are normally implemented using a stack.

Example: { Int a, b, c, =10;  local variable Char x; Float num; }

Global variables These variables can be accessed by any function comprising the program. They are implemented by associating memory locations with variable names.

Example: {Int a, b, c, =[10,20,30] ; Global variable Chal x; Float } (or) {Int a = [10] Int b = [20] Int c = [30] Chal [15] Float }

Example of Global Variable Example: { Int a, b, c, =[10,20,30] ; Char x; Float num; } { Int a = [10]; Int b = [20]; Int c = [30]; Char[15]; Float num; }

TYPEDEF STATEMENT typedef is a keyword in the C and C++ programming languages. The purpose of typedef is to assign alternative names to existing types. types declared with typedef end with ( '_t' ) (e.g., size_t, time_t) Syntax;- Typedef exp1, exp2,….., exp n

All data types in between typedef and identifier can now be referred to by the identifier alone The statement. typedef struct tnode *Treeptr; typedef struct tnode { int count; struct tnode *left; struct tnode *right; } Treenode;

Example of Typedeaf 1055

Enumerated DataTypes The data type enum allows used identifier as value Syntax: Enum identifier {Element} Element 1, Element 2…..to Element n;

Example of main program Enum days {sun, mon, tue, wed, thu, fir, sat} Enum color{red, blue, orange, pink, green,} Enum holiday{Sunday, Saturday} Enum rainbow{red, blue, orange, yellow, green,}