SlideShare une entreprise Scribd logo
1  sur  99
Télécharger pour lire hors ligne
CSEG1003 Programming for Problem Solving
CSEG 1001
Computer Programming
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
Road Map
• Generations of Computers and Languages
• Organization of Computers-Online Lecture
• Number Systems Conversion
• Logical Analysis and Thinking
Introduction to
Computers
• Structure of C Program & Compilation and Linking Process
• Variables and Datatypes
• Managing Input and Output statements and Operators
• Decision and Looping Statements
C Programming
Basics
• Creation and Usages
• 1D and 2 D arrys
• String Functions
• Matrix operations
Arrays and
Strings
• Declaration and Definitions of Functions
• Passing Arguments
• Recursion
• Pointers & Pointer Arithmetic
Functions and
Pointers
• Need of Structure and Unions
• Declaration and Definition
• Storage classes
• Preprocessor Directives
Structures and
Unions
CSEG1003 Programming for Problem
Solving
Online Lecture
• Problem Formulation
• Problem Solving
• Introduction to C
CSEG1003 Programming for Problem
Solving
LECTURE #8
STRUCTURE OF C PROGRAM ..COMPILATIONAND
LINKING
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
Structured Blocks -> Functions
• Solves a large problem
• divides the problem into smaller
modules called functions
• each have particular responsibility.
• The program which solves the
entire problem is a collection of
such functions.
• Types
• Built-in Functions (Predefined)
• E.g. printf(), scanf()
• User-defined Functions
CSEG1003 Programming for Problem
Solving
Example Program 1
#include<stdio.h>
void main()
{
printf("Hello");
printf("this is my function");
}
9Instructor: Dhiviya Rose J , AP-Sr. Scale | CIT
Example Program 2
#include<stdio.h> PREPROCESSOR DIRECTIVE
void myline(); FUNCTION DECLARATION
void main()
{
printf("Hello");
myline(); FUNCTION CALL
}
void myline()
{
printf("this is my function"); FUNCTION DEFINITION
}
10Instructor: Dhiviya Rose J , AP-Sr. Scale | CIT
Functions Example 3
CSEG1003 Programming for Problem
Solving
OUTPUT ?????
Function Call ????
Function definition???
Function Declaration????
Main Function
CSEG1003 Programming for Problem
Solving
• When system is executed it calls the main function
• Entry point of any program
• Can have void main(){……}
• where it return type is void
• Or can be int main(){……… return 0;}
• where it returns an integer.
Steps in C compilation
CSEG1003 Programming for Problem Solving
Files in a C program
CSEG1003 Programming for Problem
Solving
Binary Format
a.out ./ <obj file>
Structure
of
C
Program
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem Solving
Documentation
• Comments
• provide clarity to the C source code and allows others to better
understand
• helps in debugging the code.
• Two types
• Single Line //
• Multiline /* any text */
// This is my first Program
/* Written for Engineering students of Petroleum University for the batch
2018-1019 students */
#include <stdio.h>
void main()
{
printf(“Hello”);
}
CSEG1003 Programming for Problem
Solving
Preprocessing
• First stage of compilation
• Lines starting with a # character are interpreted by the
preprocessor as preprocessor commands.
• This language is used to reduce repetition in source code
• Print the result of the preprocessing stage, pass the -E
option to gcc:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
LECTURE #9
VARIABLES, CONSTANTS, DATATYPESAND
OPERATORS
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
Knowledge Checks
#include <stdio.h>
void solveMeFirst( )
{
int num1,num2;
scanf("%d %d",&num1,&num2);
int sum;
sum = num1+num2;
printf("%d",sum);
}
void main()
{
________________Fill me
}
CSEG1003 Programming for Problem
Solving
Knowledge Check
• C Program Specification
• 3 user defined functions
• F1 -> prints “I am F1”
• F2 -> prints “I am F2”
• F3 -> prints “I am F3”
• Required Output
I am F2
I am F3
I am F1
I am F2
CSEG1003 Programming for Problem
Solving
Keywords
• C has a set of 32 reserved words often known as
keywords.
• All keywords are basically a sequence of characters
that have a fixed meaning.
• By convention all keywords must be written in
lowercase (small) letters.
• Example: for, while, do-while, auto break, case, char,
continue, do, double, else, enum, extern, float, goto,
if, int, long, register, return, short, signed, sizeof,
static, struct, switch, typedef, union, unsigned, void,
volatile
CSEG1003 Programming for Problem
Solving
Identifiers
• Identifiers are names given to program elements such as
variables, arrays and functions.
• Rules for forming identifier name
• it cannot include any special characters or punctuation marks (like #,
$, ^, ?, ., etc) except the underscore"_".
• There cannot be two successive underscores
• Keywords cannot be used as identifiers
• The names are case sensitive. So, example, “FIRST” is different from
“first” and “First”.
• It must begin with an alphabet or an underscore.
• It can be of any reasonable length. Though it should not contain more
than 31 characters.
• Example: roll_number, marks, name, SAP_ID, COURSE,
SEM
CSEG1003 Programming for Problem
Solving
Variables
• Meaningful name given to the data storage location in
computer memory.
• C language supports two basic kinds of variables.
• Numeric variables can be used to store either integer values or
floating point values.
• While an integer value is a whole numbers without a fraction part or
decimal point, a floating point number, can have a decimal point in
them.
• Numeric values may also be associated with modifiers like short, long,
signed and unsigned.
• By default, C automatically a numeric variable signed..
• Character variables can include any letter from the alphabet or from
the ASCII chart and numbers 0 – 9 that are put between single
quotes.
CSEG1003 Programming for Problem
Solving
Data & Variable
CSEG1003 Programming for Problem
Solving
Knowledge Check - Output????
CSEG1003 Programming for Problem
Solving
Knowledge Check - Output????
CSEG1003 Programming for Problem
Solving
DataType in C language
CSEG1003 Programming for Problem
Solving
Variable Declaration / Definition
• Declaring/Definition a Variable
• Declaration announces the data type of a variable and allocates
appropriate memory location.
• Each variable used must be declared.
• A form of a declaration statement is
data-type var1, var2,…;
Examples
int sum = 0;
char t1 = ‘a’;
float epsilon = 1.44;
CSEG1003 Programming for Problem
Solving
Possible ways of Variable Declaration
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem Solving
Know your datatype char….
CSEG1003 Programming for Problem
Solving
Range of Datatypes in C
CSEG1003 Programming for Problem Solving
Global and Local Variables
• Global Variables
• These variables are
declared outside all
functions.
• Life time of a global
variable is the entire
execution period of the
program.
• Can be accessed by any
function defined below the
declaration, in a file.
• Local Variables
• These variables are
declared inside some
functions.
• Life time of a local
variable is the entire
execution period of the
function in which it is
defined.
• Cannot be accessed by any
other function.
• In general variables
declared inside a block are
accessible only in that
block.
CSEG1003 Programming for Problem Solving
Example
CSEG1003 Programming for Problem Solving
Constants
• Constants are identifiers whose value does not
change.
• To declare a constant, precede the normal variable
declaration with const keyword and assign it a value.
For example,
const float pi = 3.14;
• Another way to designate a constant is to use the pre-
processor command define.
#define PI 3.14159
CSEG1003 Programming for Problem
Solving
Operators in C
• C language supports a lot of operators to be used in
expressions. Includes
• Arithmetic operators
• Relational Operators
• Equality Operators
• Logical Operators
• Unary Operators
• Conditional Operators
• Bitwise Operators
• Assignment operators
• Comma Operator
• Sizeof Operator
CSEG1003 Programming for Problem
Solving
Arithmetic and Relational
CSEG1003 Programming for Problem
Solving
Logical and Unary
• Logical operators
• Logical AND (&&)
• Logical OR (||)
• Logical NOT (!).
• As in case of arithmetic expressions, the logical
expressions are evaluated from left to right.
• Unary operators
• act on single operands.
• Three unary operators
• unary minus(-)
• Increment(++)
• Decrement operators(--)
CSEG1003 Programming for Problem
Solving
Conditional Operator
• (?:) is just like an if .. else statement
• Syntax of the conditional operator is
exp1 ? exp2 : exp3
• Eg.
large = ( a > b) ? a : b
• Conditional operator is also known as ternary
operator as it is neither a unary nor a binary operator;
it takes three operands.
CSEG1003 Programming for Problem
Solving
Bitwise and Bitwise Shift Operators
• Bitwise operators perform operations at bit level.
• bitwise AND operator (&)
• bitwise OR operator (|)
• bitwise NOT (~)
• bitwise XOR operator (^)
• In bitwise shift operations, the digits are moved, or shifted,
to the left or right.
• Left Shift unsigned (<<)
int x = 11000101;
x << 2 = 00010100
• Right arithmetic shift (>>)
int x = 11000101;
x >> 2 = 00110001
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem Solving
Assignment, Comma Operator
CSEG1003 Programming for Problem
Solving
equal sign (=) is the fundamental assignment operator, C also supports
other assignment operators that provide shorthand ways to represent
common variable assignments.
Comma separated operands when chained together are evaluated in left-
to-right sequence with the right-most value yielding the result of the
expression.
Sizeof operator
• sizeof is a unary operator used to calculate the sizes
of data types.
• sizeof(char) returns 1, that is the size of a character
data type.
int a = 10;
int result;
result = sizeof(a);
then result = 2,
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
LECTURE #10
INPUTAND OUTPUT STATEMENTS
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
OUTPUT STATEMENT - printf()
• printf() function
• Output to Standard Output
• Prototype definition available in stdio.h
CSEG1003 Programming for Problem Solving
• Case 1: printing only text
Flowchart code Output
printf(“Hello”); Hello
• Case 2: printing only value of a variable
printf(“%d” , area); 120
• Case 3: printing text and a value
printf(“The value of area is %d”,area); The value of area is 120
Print Hello
Print area
OUTPUT STATEMENT - printf()
CSEG1003 Programming for Problem
Solving
INPUT STATEMENT – scanf()
• Case 1: getting 1 input value
scanf( “%d”, &r);
• Case 2: getting 2 input value
scanf( “%d %d ”, &l, &b);
• Case 3: getting 3 input value
scanf( “%d %d %d ”, &a, &b ,&c);
CSEG1003 Programming for Problem
Solving
• scanf() function
• Input from Standard Input
• Prototype definition available in stdio.h
• Format Specifier(%d)
• Address-of Operator (&)
• Provides the memory address of the input variable were the input value is to
be stored
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
CSEG1003 Programming for Problem Solving
DECISION STRUCTURES IN C
CSEG1003 Programming for Problem
Solving
List of Decision Making Structures in C
•If structure
•If Else structure
•Nested If structure
•Switch Structures
•Conditional Operator/
Terniary operator
CSEG1003 Programming for Problem
Solving
Converting a if block to C program
CSEG1003 Programming for Problem
Solving
if(condition)
{
//true statements
}
Check if entered number is positive
CSEG1003 Programming for Problem
Solving
Converting a if-else block to C program
CSEG1003 Programming for Problem
Solving
if(condition)
{
//true statements
}
else
{
//false statements
}
Example: If Else Statement
CSEG1003 Programming for Problem
Solving
Knowledge Checks – Implement – If… Else
CSEG1003 Programming for Problem
Solving
Nested IF
CSEG1003 Programming for Problem
Solving
if(condition 1)
{
//true statements
}
else if(condition 2)
{
//statements
}
else if(condition 3)
{
//statements
}
else
{
//statements
}
Example
CSEG1003 Programming for Problem
Solving
switch …case decision Implementation
CSEG1003 Programming for Problem
Solving
Switch Case
• Keywords used switch, case, default, break
• An value is passed as the input
• Switch(value)
• Evaluates with an value in each case
• Case 1:
• Case ‘A’:
• Default:
• Break is used to get exit from switch block
• Break;
CSEG1003 Programming for Problem
Solving
Convert Switch to C program
CSEG1003 Programming for Problem
Solving
Switch case Vs Nested IF
CSEG1003 Programming for Problem
Solving
Knowledge Check
CSEG1003 Programming for Problem
Solving
Knowledge Checks
CSEG1003 Programming for Problem
Solving
EXPERIMENT NO – 4
Control Statements in C Language
List of lab works:
1. Write a program to accept 3 numbers and find the greatest of them, using
if…….else statements.
2. Write a program to find the biggest of 3 numbers using conditional operator/ternary
operator?
3. Write a program to check whether the roots of a quadratic equation are real or
imaginary?
4. Program to find the average of students marks, if average<50 then result is ‘FAIL’
otherwise print the grade as pass /first class/distinction.
5. A book and stationary store decides to give its customers 10% discount on a
purchase greater than 10,000/-. The program should accept the quantity
purchased the price of the items and then calculate the amount payable. Further
based on the total amount, appropriate discount should be given and final payable
amount should be displayed.
6. Write a program to accept a number and display “Sunday/Monday/Tuesday…..”
Based on the number. (hint: if 1 is input then “Sunday”, if 2 is input then
“Monday”…..) using switch case.
7. Read the minutes from the keyboard and find out the no. of hours, mins , days ?
(Ex 1210 mins are displayed as 0 days,20 hrs,10 min)
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
LECTURE #13
LOOP STRUCTURES IN C
Instructor
Dhiviya Rose J . Asst. Prof. Senior Scale
School of Computer Science and Engineering | UPES
CSEG1003 Programming for Problem
Solving
Introduction - Loop Statements
• Helps in executing a statement in flowchart repeatedly
• Loop statements – block of statement executed more
than one time
• How many times the loop statements are executed is
managed by a counter variable
• Counter Variable Initialization
• Eg. C=0
• Counter Variable Increment/Decrement
• Eg. C++, c=c+1,c=c+3
• Counter Variable Condition Check
• Eg. C<3
CSEG1003 Programming for Problem
Solving
List of Loop Structures in C
• While
• Do….While
• For
CSEG1003 Programming for Problem
Solving
While
• Entry condition check loop
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
Example – While Program
CSEG1003 Programming for Problem
Solving
Do … While Loop
• Exit check Loop
• At least executes the
statement once
if the condition is false
CSEG1003 Programming for Problem
Solving
At least executes once - if condition fails
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
For
CSEG1003 Programming for Problem
Solving
Example
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
Continue statement
CSEG1003 Programming for Problem
Solving
Knowledge Check
CSEG1003 Programming for Problem
Solving
EXPERIMENT NO – 5
Loop Statements in C Language
List of lab works:
1. Write a program to print half pyramid using *.
2. Write a C program to print all natural numbers from 1-n
using while loop.
3. Write a C program to find the sum of all even numbers
between 1 to n using do-while loop.
4. Write a C program to print multiplication table of any
number using for loop.
CSEG1003 Programming for Problem
Solving
CSEG1003 Programming for Problem
Solving
KNOWLEDGE CHECKS
Input – Output Statements
CSEG1003 Programming for Problem
Solving
1. I = scanf("%d%d",&a,&b); value of I will be
2. I = sizeof(float); the value of I will be
3. i=printf("%d",20000); then i=?
4. i=printf("upes"); then i= ?
5. i=scanf("%d",&a); then i=?
CSEG1003 Programming for Problem
Solving
6. i=printf("%d",20000); then i=?
7. printf("%d",printf("%d",345)); the output of the
statement will be ?
8. printf(“%d”,’A’);
9. printf("%o",12); the output of the statement will be ?
10. printf("%d",2&2); the output of the statement will
be ?
11. printf("%.2f",78.34567);
CSEG1003 Programming for Problem
Solving
KNOWLEDGE CHECKS
Conditional and Loop Statements
CSEG1003 Programming for Problem
Solving
Question 1
#include <stdio.h>
int main()
{
int var=100;
{
int var=200;
printf("%d...",var);
}
printf("%d",var);
return 0;
}
Question 2
int main()
{
int n,i=0;
while(scanf("%d",&n)==1)
{
printf("ENDn");
break;
}
return 0;
}
Question 3
int main()
{
int n=10,i=0;
while(1)
{
printf("ENDn"); n++;
}
return 0;
}
Question 4
int a=2;
switch(a)
{
case 1:
printf(“one ”);
case 2:
printf(“two ”);
case 3:
printf(“three ”);
default:
printf(“other ”);
}
Question 5
void anyFun(int a)
{
if(a==0)
return;
printf("Value is not Zero.");
}
void main()
{
anyFun(0);
}
Question 6
#include <stdio.h>
void fun(int a,int b)
{
a+=10;
b+=10;
}
int main()
{
int val1=10;
int val2=10;
printf("nValue before function calling : %d, %d",val1,val2);
fun(val1,val2);
printf("nValue after function calling : %d, %d",val1,val2);
return 0;
}
Question 7
#include <stdio.h>
void fun1(void)
{
void fun2(void); /*another function declaration*/
printf("nI am fun1");
fun2();
}
int main()
{
fun1();
return 0;
}
void fun2(void)
{
printf("nI am fun2");
}
Question 8
for(i=1;i<=2;i++)
{
for(j=1;j<=10;j++)
{
printf("%d ",j);
}
printf("n");
}
CSEG1003 Programming for Problem
Solving

Contenu connexe

Tendances

C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
MomenMostafa
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
sharvivek
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
 

Tendances (20)

CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
C language
C languageC language
C language
 
C++
C++C++
C++
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
 
C programming
C programmingC programming
C programming
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
What is c
What is cWhat is c
What is c
 
C++ Tokens
C++ TokensC++ Tokens
C++ Tokens
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Basic Input and Output
Basic Input and OutputBasic Input and Output
Basic Input and Output
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
 
c++
 c++  c++
c++
 

Similaire à Programming for Problem Solving Unit 2

Similaire à Programming for Problem Solving Unit 2 (20)

C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
C language
C languageC language
C language
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
CSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming FundamentalsCSEG1001Unit 2 C Programming Fundamentals
CSEG1001Unit 2 C Programming Fundamentals
 
Introduction to C
Introduction to CIntroduction to C
Introduction to C
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Data structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in CData structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in C
 
Basics of c
Basics of cBasics of c
Basics of c
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
c-programming
c-programmingc-programming
c-programming
 
0-Slot05-06-07-Basic-Logics.pdf
0-Slot05-06-07-Basic-Logics.pdf0-Slot05-06-07-Basic-Logics.pdf
0-Slot05-06-07-Basic-Logics.pdf
 
C programming
C programming C programming
C programming
 
Lec-1c.pdf
Lec-1c.pdfLec-1c.pdf
Lec-1c.pdf
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 

Plus de Dhiviya Rose (14)

Module 3 microsoft powerpoint
Module 3 microsoft powerpointModule 3 microsoft powerpoint
Module 3 microsoft powerpoint
 
Module 3 business computing.pdf
Module 3 business computing.pdfModule 3 business computing.pdf
Module 3 business computing.pdf
 
Module 2 Digital Devices and its Applications
Module 2 Digital Devices and its ApplicationsModule 2 Digital Devices and its Applications
Module 2 Digital Devices and its Applications
 
Software
SoftwareSoftware
Software
 
Unit 1 Business Computing
Unit 1 Business ComputingUnit 1 Business Computing
Unit 1 Business Computing
 
Module 1 - Digital Devices and its Application
Module 1 - Digital Devices and its ApplicationModule 1 - Digital Devices and its Application
Module 1 - Digital Devices and its Application
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
 
CSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and PointersCSEG1001 Unit 4 Functions and Pointers
CSEG1001 Unit 4 Functions and Pointers
 
CSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and UnionsCSEG1001 Unit 5 Structure and Unions
CSEG1001 Unit 5 Structure and Unions
 
CSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to ComputersCSEG1001 Lecture 1 Introduction to Computers
CSEG1001 Lecture 1 Introduction to Computers
 
Lecture 3 internet and web
Lecture 3 internet and webLecture 3 internet and web
Lecture 3 internet and web
 
Strings
StringsStrings
Strings
 
Multidimentional array
Multidimentional arrayMultidimentional array
Multidimentional array
 
Searching in Arrays
Searching in ArraysSearching in Arrays
Searching in Arrays
 

Dernier

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

Programming for Problem Solving Unit 2

  • 1. CSEG1003 Programming for Problem Solving
  • 2. CSEG 1001 Computer Programming Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 3. Road Map • Generations of Computers and Languages • Organization of Computers-Online Lecture • Number Systems Conversion • Logical Analysis and Thinking Introduction to Computers • Structure of C Program & Compilation and Linking Process • Variables and Datatypes • Managing Input and Output statements and Operators • Decision and Looping Statements C Programming Basics • Creation and Usages • 1D and 2 D arrys • String Functions • Matrix operations Arrays and Strings • Declaration and Definitions of Functions • Passing Arguments • Recursion • Pointers & Pointer Arithmetic Functions and Pointers • Need of Structure and Unions • Declaration and Definition • Storage classes • Preprocessor Directives Structures and Unions CSEG1003 Programming for Problem Solving
  • 4. Online Lecture • Problem Formulation • Problem Solving • Introduction to C CSEG1003 Programming for Problem Solving
  • 5. LECTURE #8 STRUCTURE OF C PROGRAM ..COMPILATIONAND LINKING Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 6. CSEG1003 Programming for Problem Solving
  • 7. CSEG1003 Programming for Problem Solving
  • 8. Structured Blocks -> Functions • Solves a large problem • divides the problem into smaller modules called functions • each have particular responsibility. • The program which solves the entire problem is a collection of such functions. • Types • Built-in Functions (Predefined) • E.g. printf(), scanf() • User-defined Functions CSEG1003 Programming for Problem Solving
  • 9. Example Program 1 #include<stdio.h> void main() { printf("Hello"); printf("this is my function"); } 9Instructor: Dhiviya Rose J , AP-Sr. Scale | CIT
  • 10. Example Program 2 #include<stdio.h> PREPROCESSOR DIRECTIVE void myline(); FUNCTION DECLARATION void main() { printf("Hello"); myline(); FUNCTION CALL } void myline() { printf("this is my function"); FUNCTION DEFINITION } 10Instructor: Dhiviya Rose J , AP-Sr. Scale | CIT
  • 11. Functions Example 3 CSEG1003 Programming for Problem Solving OUTPUT ????? Function Call ???? Function definition??? Function Declaration????
  • 12. Main Function CSEG1003 Programming for Problem Solving • When system is executed it calls the main function • Entry point of any program • Can have void main(){……} • where it return type is void • Or can be int main(){……… return 0;} • where it returns an integer.
  • 13. Steps in C compilation CSEG1003 Programming for Problem Solving
  • 14. Files in a C program CSEG1003 Programming for Problem Solving Binary Format a.out ./ <obj file>
  • 16. CSEG1003 Programming for Problem Solving
  • 17. Documentation • Comments • provide clarity to the C source code and allows others to better understand • helps in debugging the code. • Two types • Single Line // • Multiline /* any text */ // This is my first Program /* Written for Engineering students of Petroleum University for the batch 2018-1019 students */ #include <stdio.h> void main() { printf(“Hello”); } CSEG1003 Programming for Problem Solving
  • 18. Preprocessing • First stage of compilation • Lines starting with a # character are interpreted by the preprocessor as preprocessor commands. • This language is used to reduce repetition in source code • Print the result of the preprocessing stage, pass the -E option to gcc: #include <stdio.h> #include <stdlib.h> #include <string.h> CSEG1003 Programming for Problem Solving
  • 19. CSEG1003 Programming for Problem Solving
  • 20. LECTURE #9 VARIABLES, CONSTANTS, DATATYPESAND OPERATORS Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 21. Knowledge Checks #include <stdio.h> void solveMeFirst( ) { int num1,num2; scanf("%d %d",&num1,&num2); int sum; sum = num1+num2; printf("%d",sum); } void main() { ________________Fill me } CSEG1003 Programming for Problem Solving
  • 22. Knowledge Check • C Program Specification • 3 user defined functions • F1 -> prints “I am F1” • F2 -> prints “I am F2” • F3 -> prints “I am F3” • Required Output I am F2 I am F3 I am F1 I am F2 CSEG1003 Programming for Problem Solving
  • 23. Keywords • C has a set of 32 reserved words often known as keywords. • All keywords are basically a sequence of characters that have a fixed meaning. • By convention all keywords must be written in lowercase (small) letters. • Example: for, while, do-while, auto break, case, char, continue, do, double, else, enum, extern, float, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile CSEG1003 Programming for Problem Solving
  • 24. Identifiers • Identifiers are names given to program elements such as variables, arrays and functions. • Rules for forming identifier name • it cannot include any special characters or punctuation marks (like #, $, ^, ?, ., etc) except the underscore"_". • There cannot be two successive underscores • Keywords cannot be used as identifiers • The names are case sensitive. So, example, “FIRST” is different from “first” and “First”. • It must begin with an alphabet or an underscore. • It can be of any reasonable length. Though it should not contain more than 31 characters. • Example: roll_number, marks, name, SAP_ID, COURSE, SEM CSEG1003 Programming for Problem Solving
  • 25. Variables • Meaningful name given to the data storage location in computer memory. • C language supports two basic kinds of variables. • Numeric variables can be used to store either integer values or floating point values. • While an integer value is a whole numbers without a fraction part or decimal point, a floating point number, can have a decimal point in them. • Numeric values may also be associated with modifiers like short, long, signed and unsigned. • By default, C automatically a numeric variable signed.. • Character variables can include any letter from the alphabet or from the ASCII chart and numbers 0 – 9 that are put between single quotes. CSEG1003 Programming for Problem Solving
  • 26. Data & Variable CSEG1003 Programming for Problem Solving
  • 27. Knowledge Check - Output???? CSEG1003 Programming for Problem Solving
  • 28. Knowledge Check - Output???? CSEG1003 Programming for Problem Solving
  • 29. DataType in C language CSEG1003 Programming for Problem Solving
  • 30. Variable Declaration / Definition • Declaring/Definition a Variable • Declaration announces the data type of a variable and allocates appropriate memory location. • Each variable used must be declared. • A form of a declaration statement is data-type var1, var2,…; Examples int sum = 0; char t1 = ‘a’; float epsilon = 1.44; CSEG1003 Programming for Problem Solving
  • 31. Possible ways of Variable Declaration CSEG1003 Programming for Problem Solving
  • 32. CSEG1003 Programming for Problem Solving
  • 33. Know your datatype char…. CSEG1003 Programming for Problem Solving
  • 34. Range of Datatypes in C CSEG1003 Programming for Problem Solving
  • 35. Global and Local Variables • Global Variables • These variables are declared outside all functions. • Life time of a global variable is the entire execution period of the program. • Can be accessed by any function defined below the declaration, in a file. • Local Variables • These variables are declared inside some functions. • Life time of a local variable is the entire execution period of the function in which it is defined. • Cannot be accessed by any other function. • In general variables declared inside a block are accessible only in that block. CSEG1003 Programming for Problem Solving
  • 37. Constants • Constants are identifiers whose value does not change. • To declare a constant, precede the normal variable declaration with const keyword and assign it a value. For example, const float pi = 3.14; • Another way to designate a constant is to use the pre- processor command define. #define PI 3.14159 CSEG1003 Programming for Problem Solving
  • 38. Operators in C • C language supports a lot of operators to be used in expressions. Includes • Arithmetic operators • Relational Operators • Equality Operators • Logical Operators • Unary Operators • Conditional Operators • Bitwise Operators • Assignment operators • Comma Operator • Sizeof Operator CSEG1003 Programming for Problem Solving
  • 39. Arithmetic and Relational CSEG1003 Programming for Problem Solving
  • 40. Logical and Unary • Logical operators • Logical AND (&&) • Logical OR (||) • Logical NOT (!). • As in case of arithmetic expressions, the logical expressions are evaluated from left to right. • Unary operators • act on single operands. • Three unary operators • unary minus(-) • Increment(++) • Decrement operators(--) CSEG1003 Programming for Problem Solving
  • 41. Conditional Operator • (?:) is just like an if .. else statement • Syntax of the conditional operator is exp1 ? exp2 : exp3 • Eg. large = ( a > b) ? a : b • Conditional operator is also known as ternary operator as it is neither a unary nor a binary operator; it takes three operands. CSEG1003 Programming for Problem Solving
  • 42. Bitwise and Bitwise Shift Operators • Bitwise operators perform operations at bit level. • bitwise AND operator (&) • bitwise OR operator (|) • bitwise NOT (~) • bitwise XOR operator (^) • In bitwise shift operations, the digits are moved, or shifted, to the left or right. • Left Shift unsigned (<<) int x = 11000101; x << 2 = 00010100 • Right arithmetic shift (>>) int x = 11000101; x >> 2 = 00110001 CSEG1003 Programming for Problem Solving
  • 43. CSEG1003 Programming for Problem Solving
  • 44. Assignment, Comma Operator CSEG1003 Programming for Problem Solving equal sign (=) is the fundamental assignment operator, C also supports other assignment operators that provide shorthand ways to represent common variable assignments. Comma separated operands when chained together are evaluated in left- to-right sequence with the right-most value yielding the result of the expression.
  • 45. Sizeof operator • sizeof is a unary operator used to calculate the sizes of data types. • sizeof(char) returns 1, that is the size of a character data type. int a = 10; int result; result = sizeof(a); then result = 2, CSEG1003 Programming for Problem Solving
  • 46. CSEG1003 Programming for Problem Solving
  • 47. LECTURE #10 INPUTAND OUTPUT STATEMENTS Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 48. OUTPUT STATEMENT - printf() • printf() function • Output to Standard Output • Prototype definition available in stdio.h CSEG1003 Programming for Problem Solving
  • 49. • Case 1: printing only text Flowchart code Output printf(“Hello”); Hello • Case 2: printing only value of a variable printf(“%d” , area); 120 • Case 3: printing text and a value printf(“The value of area is %d”,area); The value of area is 120 Print Hello Print area OUTPUT STATEMENT - printf() CSEG1003 Programming for Problem Solving
  • 50. INPUT STATEMENT – scanf() • Case 1: getting 1 input value scanf( “%d”, &r); • Case 2: getting 2 input value scanf( “%d %d ”, &l, &b); • Case 3: getting 3 input value scanf( “%d %d %d ”, &a, &b ,&c); CSEG1003 Programming for Problem Solving
  • 51. • scanf() function • Input from Standard Input • Prototype definition available in stdio.h • Format Specifier(%d) • Address-of Operator (&) • Provides the memory address of the input variable were the input value is to be stored CSEG1003 Programming for Problem Solving
  • 52. CSEG1003 Programming for Problem Solving
  • 53. CSEG1003 Programming for Problem Solving
  • 54. DECISION STRUCTURES IN C CSEG1003 Programming for Problem Solving
  • 55. List of Decision Making Structures in C •If structure •If Else structure •Nested If structure •Switch Structures •Conditional Operator/ Terniary operator CSEG1003 Programming for Problem Solving
  • 56. Converting a if block to C program CSEG1003 Programming for Problem Solving if(condition) { //true statements }
  • 57. Check if entered number is positive CSEG1003 Programming for Problem Solving
  • 58. Converting a if-else block to C program CSEG1003 Programming for Problem Solving if(condition) { //true statements } else { //false statements }
  • 59. Example: If Else Statement CSEG1003 Programming for Problem Solving
  • 60. Knowledge Checks – Implement – If… Else CSEG1003 Programming for Problem Solving
  • 61. Nested IF CSEG1003 Programming for Problem Solving if(condition 1) { //true statements } else if(condition 2) { //statements } else if(condition 3) { //statements } else { //statements }
  • 63. switch …case decision Implementation CSEG1003 Programming for Problem Solving
  • 64. Switch Case • Keywords used switch, case, default, break • An value is passed as the input • Switch(value) • Evaluates with an value in each case • Case 1: • Case ‘A’: • Default: • Break is used to get exit from switch block • Break; CSEG1003 Programming for Problem Solving
  • 65. Convert Switch to C program CSEG1003 Programming for Problem Solving
  • 66. Switch case Vs Nested IF CSEG1003 Programming for Problem Solving
  • 69. EXPERIMENT NO – 4 Control Statements in C Language List of lab works: 1. Write a program to accept 3 numbers and find the greatest of them, using if…….else statements. 2. Write a program to find the biggest of 3 numbers using conditional operator/ternary operator? 3. Write a program to check whether the roots of a quadratic equation are real or imaginary? 4. Program to find the average of students marks, if average<50 then result is ‘FAIL’ otherwise print the grade as pass /first class/distinction. 5. A book and stationary store decides to give its customers 10% discount on a purchase greater than 10,000/-. The program should accept the quantity purchased the price of the items and then calculate the amount payable. Further based on the total amount, appropriate discount should be given and final payable amount should be displayed. 6. Write a program to accept a number and display “Sunday/Monday/Tuesday…..” Based on the number. (hint: if 1 is input then “Sunday”, if 2 is input then “Monday”…..) using switch case. 7. Read the minutes from the keyboard and find out the no. of hours, mins , days ? (Ex 1210 mins are displayed as 0 days,20 hrs,10 min) CSEG1003 Programming for Problem Solving
  • 70. CSEG1003 Programming for Problem Solving
  • 71. LECTURE #13 LOOP STRUCTURES IN C Instructor Dhiviya Rose J . Asst. Prof. Senior Scale School of Computer Science and Engineering | UPES CSEG1003 Programming for Problem Solving
  • 72. Introduction - Loop Statements • Helps in executing a statement in flowchart repeatedly • Loop statements – block of statement executed more than one time • How many times the loop statements are executed is managed by a counter variable • Counter Variable Initialization • Eg. C=0 • Counter Variable Increment/Decrement • Eg. C++, c=c+1,c=c+3 • Counter Variable Condition Check • Eg. C<3 CSEG1003 Programming for Problem Solving
  • 73. List of Loop Structures in C • While • Do….While • For CSEG1003 Programming for Problem Solving
  • 74. While • Entry condition check loop CSEG1003 Programming for Problem Solving
  • 75. CSEG1003 Programming for Problem Solving
  • 76. Example – While Program CSEG1003 Programming for Problem Solving
  • 77. Do … While Loop • Exit check Loop • At least executes the statement once if the condition is false CSEG1003 Programming for Problem Solving
  • 78. At least executes once - if condition fails CSEG1003 Programming for Problem Solving
  • 79. CSEG1003 Programming for Problem Solving
  • 80. For CSEG1003 Programming for Problem Solving
  • 82. CSEG1003 Programming for Problem Solving
  • 85. EXPERIMENT NO – 5 Loop Statements in C Language List of lab works: 1. Write a program to print half pyramid using *. 2. Write a C program to print all natural numbers from 1-n using while loop. 3. Write a C program to find the sum of all even numbers between 1 to n using do-while loop. 4. Write a C program to print multiplication table of any number using for loop. CSEG1003 Programming for Problem Solving
  • 86. CSEG1003 Programming for Problem Solving
  • 87. KNOWLEDGE CHECKS Input – Output Statements CSEG1003 Programming for Problem Solving
  • 88. 1. I = scanf("%d%d",&a,&b); value of I will be 2. I = sizeof(float); the value of I will be 3. i=printf("%d",20000); then i=? 4. i=printf("upes"); then i= ? 5. i=scanf("%d",&a); then i=? CSEG1003 Programming for Problem Solving
  • 89. 6. i=printf("%d",20000); then i=? 7. printf("%d",printf("%d",345)); the output of the statement will be ? 8. printf(“%d”,’A’); 9. printf("%o",12); the output of the statement will be ? 10. printf("%d",2&2); the output of the statement will be ? 11. printf("%.2f",78.34567); CSEG1003 Programming for Problem Solving
  • 90. KNOWLEDGE CHECKS Conditional and Loop Statements CSEG1003 Programming for Problem Solving
  • 91. Question 1 #include <stdio.h> int main() { int var=100; { int var=200; printf("%d...",var); } printf("%d",var); return 0; }
  • 92. Question 2 int main() { int n,i=0; while(scanf("%d",&n)==1) { printf("ENDn"); break; } return 0; }
  • 93. Question 3 int main() { int n=10,i=0; while(1) { printf("ENDn"); n++; } return 0; }
  • 94. Question 4 int a=2; switch(a) { case 1: printf(“one ”); case 2: printf(“two ”); case 3: printf(“three ”); default: printf(“other ”); }
  • 95. Question 5 void anyFun(int a) { if(a==0) return; printf("Value is not Zero."); } void main() { anyFun(0); }
  • 96. Question 6 #include <stdio.h> void fun(int a,int b) { a+=10; b+=10; } int main() { int val1=10; int val2=10; printf("nValue before function calling : %d, %d",val1,val2); fun(val1,val2); printf("nValue after function calling : %d, %d",val1,val2); return 0; }
  • 97. Question 7 #include <stdio.h> void fun1(void) { void fun2(void); /*another function declaration*/ printf("nI am fun1"); fun2(); } int main() { fun1(); return 0; } void fun2(void) { printf("nI am fun2"); }
  • 99. CSEG1003 Programming for Problem Solving