LESSON 3 IO, Variables and Operators

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

C++ Basics Variables, Identifiers, Assignments, Input/Output.
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.
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).
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
© 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.
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.
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.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
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.
CMSC 1041 Variables in C Declaring, Naming, Using Variables.
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.
2. C FUNDAMENTALS. Example: Printing a Message /* Illustrates comments, strings, and the printf function */ #include int main(void) { printf("To C, or.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Variables, Identifiers, Assignments, Input/Output
Basics (Variables, Assignments, I/O)
Data types Data types Basic types
C Fundamentals & Pointers
C Short Overview Lembit Jürimägi.
Basics (Variables, Assignments, I/O)
Introduction to C Programming Language
مبانی کامپیوتر و برنامه سازی
CMSC 104, Section 4 Richard Chang
Introduction to C Programming
CSE101-Lec#3 Components of C Identifiers and Keywords Data types.
Reserved Words.
Visit for more Learning Resources
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CMSC 104, Section 4 Richard Chang
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’.
פרטים נוספים בסילבוס של הקורס
Govt. Polytechnic,Dhangar
Variables, Identifiers, Assignments, Input/Output
Variables in C Topics Naming Variables Declaring Variables
UMBC CMSC 104 – Section 01, Fall 2016
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.
Govt. Polytechnic,Dhangar
Variables in C Declaring , Naming, and Using Variables.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
Module 2 Variables, Data Types and Arithmetic
Building Blocks of C Programming 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
Course Outcomes of Programming In C (PIC) (17212, C203):
Variables in C Topics Naming Variables Declaring Variables
INTRODUCTION TO C.
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

LESSON 3 IO, Variables and Operators

Review 1 #include(stdio.h) #include<conio.H> void Main() { printf(“English /n”); print(“Physics”); printf(“Chem”) get ch; } Find the syntax error in each line.

Sample Code What is the output of the program? #include <stdio.h> #include <conio.h> void main() { clrscr(); // printf(“English \n”); /* printf(“Physics”); printf(“Chemistry”);*/ printf(“Engineering Workshop”); getch(); } What is the output of the program?

Review 2 Find the syntax error in each line. #include<stdio.h> #include<conio.h> void main(); { printF(“English \n”); printf(Physics”); printf(‘Chem’); /printf(“Math”); /*printf(“Math”); getch(); } Find the syntax error in each line.

Variable Memory places to store data. 123 Total

Data Types

Rules in Naming a Variable Variables must consist of letters, digits and underscore (_) only. It should not be a keyword. White space is not allowed. Special characters/symbol NOT allowed. In one program 2 variables cant have the same name.

C Keywords auto break case char const continue default do double else enum extern float for goto if inline int long register return short signed sizeof static struct switch typedef union unsigned void volatile while

Valid/Invalid Variable Names X int Name double first@name NAME name2 first_name _name first-name 2name first name v.a.l.u.e

Format Specifier

Sample Code Write a program that will print the following output: #include<stdio.h> #include<conio.h> void main(); { int value1 = 10; float value2 = 3.1416; double value3 = 123.456; char value4 = ‘C’; printf(“Value 1: %d \n”, value1); printf(“Value 2: %f \n”, value2); printf(“Value 3: %1f \n”, value3); printf(“Value 4: %c \n”, value4); getch(); } Write a program that will print the following output: Value 1: 10 Value 2: 3.1416 Value 3: 123.456 Value 4: C Store the initial values to a variable.

Tell what data type will you use for the following data? Sample Declaration 10 936.36 50000 ‘x’ 412.00

Tell what data type will you use for the following data? Sample Declaration 10 int int n1=10; 936.36 float float n2=936.36; 50000 int n3=50000; ‘x’ char char n4=‘x’; 412.00 float n5=412.00

Write a program that adds two integers of 30 and 10. Problem Write a program that adds two integers of 30 and 10.

Solution #include<stdio.h> #include<conio.h> void main() { int n1,n2,sum; n1=30; n2=10; sum=n1+n2; printf(“Sum result of %d and %d = %d”, n1,n2,sum); getch(); }

Problem Write a program that reads two integers from keyboard and finds the addition of two the two numbers.

Solution #include<stdio.h> #include<conio.h> void main() { int n1,n2,sum; printf(“Enter first number”); scanf(“%d”,&n1); printf(“Enter second number”); scanf(“%d”,&n2); sum=n1+n2; printf(“Sum result of %d and %d = %d”, n1,n2,sum); getch(); }

Arithmetic Operators

C Language Expression

Precedence of Operators