SlideShare a Scribd company logo
1 of 12
Download to read offline
Introduction to Computers and
Programming (CSC103)
Lecture 04
2
void main (void)
{
printf("Testing...n..1n...2n....3n")
}
Compilation Result?
#include <stdio.h>
void main (void)
{
value1 = 50;
value2 = 25;
int value1, value2, sum;
sum = value1 + value2;
printf("The sum of %d and %d is %dn", value1, value2, sum);
}
Compilation Result?
1
2
3
#include <stdio.h>
void main (void)
{
printf ("Testing...n..1n...2n....3n");
}
Output?
#include <stdio.h>
void main (void)
{
int value1, value2, sum;
value1 = 50;
value2 = 25;
sum = value1 + value2;
printf("The sum of %d and %d is %dn", value1, value2, sum);
}
Output?
1
2
Arithmetic Instructions in C
4
int ad ;
float kot, deta, alpha, beta, gamma;
ad = 3200 ;
kot = 0.0056 ;
deta = alpha * beta / gamma + 3.2 * 2 / 5 ;
---------------------------------------------------------------------------------
Here,
*, /, -, + are the arithmetic operators.
= is the assignment operator.
2, 5 and 3200 are integer constants.
3.2 and 0.0056 are real constants.
ad is an integer variable.
kot, deta, alpha, beta, gamma are real variables.
Variable Declaration and Use
5
Correct Incorrect
float a = 1.5, b = a + 3.1; float b = a + 3.1, a = 1.5;
int a, b, c, d ;
a = b = c = 10 ;
int a = b = c = d = 10;
int x, y, z;
x = y * z;
int x, y, z;
y * z = x;
Cannot Use aVariable before declaring it!
Integer and Float Conversion
6
 Implicit and Explicit Conversions
 An arithmetic operation between an integer and integer
always yields an integer result.
 An operation between a real and real always yields a real
result.
 An operation between an integer and real always yields a real
result. In this operation the integer is first promoted to a real
and then the operation is performed. Hence the result is real.
7
int i ;
float b ;
i = 3.5 ;
b = 30 ;
 What would be the value of i and b?
 Think of Integer and Float Conversion
8
 k is an integer variable
 a is a real/float variable
Receiving User Input
 To get the input from the user we use a library function called
scanf()
 The format of scanf() is;
scanf(“<format specifier>”, &<variable name>);
 format specifier shows what type of data you want to input or get
from user
 & before the variable name is must
 & is an “Address of Operator”
 It gives the location number used by the variable in memory
 &num tells the scanf() function at which memory location should
it store the value supplied by the user
 a blank, a tab or a new line (pressing enter) must separate the values
supplied to scanf()
Example: scanf(“%d %d %f”, &p,&n,&r);
9
Example
#include<stdio.h>
void main()
{
int num;
printf(“Enter an Integer: ”);
scanf(“%d”, &num);
printf(“You entered the number %d”, num);
}
Output?
10
Example # 2
11
#include<stdio.h>
void main()
{
int x, y;
scanf("%d%d",&x,&y);
printf(“You have entered x=%d, y=%d",x,y);
}
Output?
Evaluate yourself!
12
 Point out the errors, if any, in the following C statements:
(a) int = 314.562 * 150 ;
(b) name = ‘Ajay’ ;
(c) varchar = ‘3’ ;
(d) 3.14 * r * r * h = vol_of_cyl ;
(e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ;
(f) m_inst = rate of interest * amount in rs ;

More Related Content

What's hot

C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2Zaibi Gondal
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4Rumman Ansari
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in cmohdshanu
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c languageMomenMostafa
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointerargusacademy
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
function in c
function in cfunction in c
function in csubam3
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...hwbloom27
 
Simple c program
Simple c programSimple c program
Simple c programRavi Singh
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloadingmohamed sikander
 
Mathematics Function in C ,ppt
Mathematics Function in C ,pptMathematics Function in C ,ppt
Mathematics Function in C ,pptAllNewTeach
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program Rumman Ansari
 

What's hot (20)

C programming Lab 2
C programming Lab 2C programming Lab 2
C programming Lab 2
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in c
 
1 introducing c language
1  introducing c language1  introducing c language
1 introducing c language
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
function in c
function in cfunction in c
function in c
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...
 
Simple c program
Simple c programSimple c program
Simple c program
 
Functions
FunctionsFunctions
Functions
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
 
Mathematics Function in C ,ppt
Mathematics Function in C ,pptMathematics Function in C ,ppt
Mathematics Function in C ,ppt
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
6. function
6. function6. function
6. function
 

Viewers also liked

Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03hassaanciit
 
Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2hassaanciit
 
Introduction to Computer and Programming - Lecture 02
Introduction to Computer and Programming - Lecture 02Introduction to Computer and Programming - Lecture 02
Introduction to Computer and Programming - Lecture 02hassaanciit
 
Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01hassaanciit
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming conceptssalmankhan570
 
Computer programing
Computer programingComputer programing
Computer programingJT Taylor
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010leo lapworth
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2Warawut
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429Edmund Sowah
 
Islamic Studies - Lecture#1 (Religion)
Islamic Studies - Lecture#1 (Religion)Islamic Studies - Lecture#1 (Religion)
Islamic Studies - Lecture#1 (Religion)hassaanciit
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programmingJordan Delacruz
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming692sfrobotics
 
PowerPoint for Introduction to Office 2010
PowerPoint for Introduction to Office 2010PowerPoint for Introduction to Office 2010
PowerPoint for Introduction to Office 2010mindysholder
 

Viewers also liked (20)

Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03
 
Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2
 
Introduction to Computer and Programming - Lecture 02
Introduction to Computer and Programming - Lecture 02Introduction to Computer and Programming - Lecture 02
Introduction to Computer and Programming - Lecture 02
 
Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01Introduction to Computer and Programming - Lecture 01
Introduction to Computer and Programming - Lecture 01
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Basic programming
Basic programmingBasic programming
Basic programming
 
Computer Programing
Computer ProgramingComputer Programing
Computer Programing
 
Computer programing
Computer programingComputer programing
Computer programing
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
 
Programing techniques
Programing techniquesPrograming techniques
Programing techniques
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429
 
Sharia
ShariaSharia
Sharia
 
Islamic Studies - Lecture#1 (Religion)
Islamic Studies - Lecture#1 (Religion)Islamic Studies - Lecture#1 (Religion)
Islamic Studies - Lecture#1 (Religion)
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
What is Sharia Law?
What is Sharia Law?What is Sharia Law?
What is Sharia Law?
 
PowerPoint for Introduction to Office 2010
PowerPoint for Introduction to Office 2010PowerPoint for Introduction to Office 2010
PowerPoint for Introduction to Office 2010
 
Islam s6 shari'a law and dhimmi
Islam s6 shari'a law and dhimmiIslam s6 shari'a law and dhimmi
Islam s6 shari'a law and dhimmi
 

Similar to Introduction to Computer and Programing - Lecture 04

Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxhappycocoman
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143alish sha
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 

Similar to Introduction to Computer and Programing - Lecture 04 (20)

Function in c program
Function in c programFunction in c program
Function in c program
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C programs
C programsC programs
C programs
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
7 functions
7  functions7  functions
7 functions
 
Functions in c
Functions in cFunctions in c
Functions in c
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Functions
FunctionsFunctions
Functions
 
C function
C functionC function
C function
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 

More from hassaanciit

Circuits Lecture 5 with examples
Circuits Lecture 5 with examplesCircuits Lecture 5 with examples
Circuits Lecture 5 with exampleshassaanciit
 
Calculus - Functions Review
Calculus - Functions ReviewCalculus - Functions Review
Calculus - Functions Reviewhassaanciit
 
Ex 1 3_fsc_part1
Ex 1 3_fsc_part1Ex 1 3_fsc_part1
Ex 1 3_fsc_part1hassaanciit
 
Islamic Studies - Fundamental beliefs
Islamic Studies - Fundamental beliefsIslamic Studies - Fundamental beliefs
Islamic Studies - Fundamental beliefshassaanciit
 
Islamic Studies - Concepts About Religion
Islamic Studies - Concepts About ReligionIslamic Studies - Concepts About Religion
Islamic Studies - Concepts About Religionhassaanciit
 
Islamic Studies - Course Outline
Islamic Studies - Course OutlineIslamic Studies - Course Outline
Islamic Studies - Course Outlinehassaanciit
 

More from hassaanciit (7)

Circuits Lecture 5 with examples
Circuits Lecture 5 with examplesCircuits Lecture 5 with examples
Circuits Lecture 5 with examples
 
ICP - Lecture 9
ICP - Lecture 9ICP - Lecture 9
ICP - Lecture 9
 
Calculus - Functions Review
Calculus - Functions ReviewCalculus - Functions Review
Calculus - Functions Review
 
Ex 1 3_fsc_part1
Ex 1 3_fsc_part1Ex 1 3_fsc_part1
Ex 1 3_fsc_part1
 
Islamic Studies - Fundamental beliefs
Islamic Studies - Fundamental beliefsIslamic Studies - Fundamental beliefs
Islamic Studies - Fundamental beliefs
 
Islamic Studies - Concepts About Religion
Islamic Studies - Concepts About ReligionIslamic Studies - Concepts About Religion
Islamic Studies - Concepts About Religion
 
Islamic Studies - Course Outline
Islamic Studies - Course OutlineIslamic Studies - Course Outline
Islamic Studies - Course Outline
 

Recently uploaded

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Introduction to Computer and Programing - Lecture 04

  • 1. Introduction to Computers and Programming (CSC103) Lecture 04
  • 2. 2 void main (void) { printf("Testing...n..1n...2n....3n") } Compilation Result? #include <stdio.h> void main (void) { value1 = 50; value2 = 25; int value1, value2, sum; sum = value1 + value2; printf("The sum of %d and %d is %dn", value1, value2, sum); } Compilation Result? 1 2
  • 3. 3 #include <stdio.h> void main (void) { printf ("Testing...n..1n...2n....3n"); } Output? #include <stdio.h> void main (void) { int value1, value2, sum; value1 = 50; value2 = 25; sum = value1 + value2; printf("The sum of %d and %d is %dn", value1, value2, sum); } Output? 1 2
  • 4. Arithmetic Instructions in C 4 int ad ; float kot, deta, alpha, beta, gamma; ad = 3200 ; kot = 0.0056 ; deta = alpha * beta / gamma + 3.2 * 2 / 5 ; --------------------------------------------------------------------------------- Here, *, /, -, + are the arithmetic operators. = is the assignment operator. 2, 5 and 3200 are integer constants. 3.2 and 0.0056 are real constants. ad is an integer variable. kot, deta, alpha, beta, gamma are real variables.
  • 5. Variable Declaration and Use 5 Correct Incorrect float a = 1.5, b = a + 3.1; float b = a + 3.1, a = 1.5; int a, b, c, d ; a = b = c = 10 ; int a = b = c = d = 10; int x, y, z; x = y * z; int x, y, z; y * z = x; Cannot Use aVariable before declaring it!
  • 6. Integer and Float Conversion 6  Implicit and Explicit Conversions  An arithmetic operation between an integer and integer always yields an integer result.  An operation between a real and real always yields a real result.  An operation between an integer and real always yields a real result. In this operation the integer is first promoted to a real and then the operation is performed. Hence the result is real.
  • 7. 7 int i ; float b ; i = 3.5 ; b = 30 ;  What would be the value of i and b?  Think of Integer and Float Conversion
  • 8. 8  k is an integer variable  a is a real/float variable
  • 9. Receiving User Input  To get the input from the user we use a library function called scanf()  The format of scanf() is; scanf(“<format specifier>”, &<variable name>);  format specifier shows what type of data you want to input or get from user  & before the variable name is must  & is an “Address of Operator”  It gives the location number used by the variable in memory  &num tells the scanf() function at which memory location should it store the value supplied by the user  a blank, a tab or a new line (pressing enter) must separate the values supplied to scanf() Example: scanf(“%d %d %f”, &p,&n,&r); 9
  • 10. Example #include<stdio.h> void main() { int num; printf(“Enter an Integer: ”); scanf(“%d”, &num); printf(“You entered the number %d”, num); } Output? 10
  • 11. Example # 2 11 #include<stdio.h> void main() { int x, y; scanf("%d%d",&x,&y); printf(“You have entered x=%d, y=%d",x,y); } Output?
  • 12. Evaluate yourself! 12  Point out the errors, if any, in the following C statements: (a) int = 314.562 * 150 ; (b) name = ‘Ajay’ ; (c) varchar = ‘3’ ; (d) 3.14 * r * r * h = vol_of_cyl ; (e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ; (f) m_inst = rate of interest * amount in rs ;