Download presentation
Presentation is loading. Please wait.
1
CSCE 206 Lab Structured Programming in C
Fall 2018 Lecture 5 Ehsanul Haque Nirjhar
2
Function Block of code to perform a specific task
A large problem can be solved using different functions User defined functions can take different parameters and return a result, which can be used in the main function Example: pow(base, exponent)takes 2 parameters as input and returns a result. It is a built-in function; not user- defined.
3
Function Syntax
4
Function Calling
5
Function Calling
6
Practice Problem-1 Write a program that reads in an integer value for n and then sums the integers from n to 2*n if n is nonnegative, or from 2 * n to n if n is negative. Hint: Use function for the summation of series.
7
Practice Problem-2 Write a program that prints all the prime numbers from 2 to Hint: Use function to check whether a number is prime or not.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.