Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
Add to Playlist
Report
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
Follow
10/17/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone, today I am going to make the sum of square of first three odd numbers in
00:08
C. I am going to make the program in C, just watch. I am going to open a new file and I
00:24
will save it also, prgsq something, I have given the name to it and save it. First thing
00:37
what I will do, I will use what hash include, hash tdio.h and I will use int main. Now let
00:48
us think about the variables int, first of all od for the odd number, sq to get the square of it,
00:56
s for the sum and i to carry on the loop and I will initialize the value, od equals to 1,
01:04
s equals to 0. I will apply the loop, i equals to 1, how many times the loop is going to work,
01:17
so i less than equal to 3 and then what i++. Inside here first thing I will do,
01:26
write down the equation to get the square of odd number. Then I need to do the sum,
01:34
so s equals to s plus sq and then I have to increment the odd, so od equals to od plus 2.
01:43
When the loop will terminate then only I will use what slash n sum of square of first three
02:07
odd numbers, that is what percent d and where it is, it is inside s. Let us save it and run it,
02:31
let me click on build, so it is showing zero errors and let us run it, so it should show
02:39
the sum of square of first three odd numbers 35, so it is showing correct result.
02:46
To clearly understand it, I have taken od, sq, s and i variables, I have initialized the value of
02:55
od, it is 1, I have initialized the value of s, that is what 0, the value of i, it is 1,
03:01
it will come to the decision part, 1 less than 3, the condition is true. What is inside od,
03:07
it is 1, so 1 into 1, so the value inside sq will be 1. Inside s, the value is what 0,
03:16
inside sq it is 1, so 0 plus 1 is 1, so now inside s it is 1 and 1 plus 2, it is 3,
03:25
the loop will carry on, the value of i is going to increment by 1, that is 2, 2 less than 3,
03:32
the condition is true. What is inside od, it is 3, so 3 into 3, 9, so new value inside sq is 9.
03:41
Inside s, it was 1, so 1 and what is now inside sq, it is 9, so 1 plus 9,
03:50
now new value inside s is 10, please remember that inside s, now it is 10,
03:56
then 3 plus 2, it is 5, so new value inside od is what 5, value of i is going to increment by 1,
04:04
so now from 2, it is what 3, 3 equals to 3, the condition is true. What is inside od, it is 5,
04:11
so 5 into 5, 25, inside sq, it is 25. What was inside s, it is 10, it was 10, inside sq, it is
04:23
25, so 10 plus 25, new value inside s is 35 and what 5 plus 2, 7, i is going to increment by 1,
04:35
that is from 3 to what 4, 4 less than 3, condition will get false, this loop will terminate,
04:44
the for loop is going to terminate and what was the last value or what is the last value inside
04:50
s, it is 35, that is going to display after the termination of the loop,
04:55
sum of square of first three odd numbers, 35.
Recommended
8:01
|
Up next
Learn Programming Technique C to Master Skills - Loop Within Loop Program
Tutorials Arena
10/17/2024
9:58
Learn Programming Technique C to Master Skills - Third Program of Array
Tutorials Arena
11/1/2024
11:15
Learn Programming Technique C to MasterĀ Skills - Third Program of Function
Tutorials Arena
11/6/2024
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second Program
Tutorials Arena
10/17/2024
3:27
Learn Programming Technique C to Master Skills - Third Program of Loop ( Flow Chart)
Tutorials Arena
10/17/2024
10:56
Learn Programming Technique C to Master Skills - Loop With If Statement Program
Tutorials Arena
10/13/2024
3:51
Learn Programming Technique C to Master Skills - First Program of Loop (For Loop)
Tutorials Arena
10/13/2024
7:49
Learn Programming Technique C to Master Skills - Third Program - Call by Reference
Tutorials Arena
11/8/2024
4:03
Learn Programming Technique C to Master Skills - Second Program of Loop ( For Loop )
Tutorials Arena
10/17/2024
4:28
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( For Loop )
Tutorials Arena
10/13/2024
12:06
Learn Programming Technique C to Master Skills - Continuous If Statement Program
Tutorials Arena
10/8/2024
5:33
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( While Loop )
Tutorials Arena
10/13/2024
3:55
Learn Programming Technique C to Master Skills - First Program of Loop (While Loop)
Tutorials Arena
10/13/2024
9:59
Learn Programming Technique C to Master SkillsCharacter String Third Program
Tutorials Arena
11/19/2024
9:20
Learn Programming Technique C to Master Skills - Union Program
Tutorials Arena
11/10/2024
9:12
Learn Programming Technique C to Master Skills - Program of Recursion
Tutorials Arena
11/6/2024
8:08
Learn Programming Technique C to MasterĀ Skills - First Program of Function
Tutorials Arena
11/3/2024
11:41
Learn Programming Technique C to Master Skills - Second Program of Array
Tutorials Arena
11/1/2024
4:07
Learn Programming Technique C to Master Skills - Second Program of Loop (While Loop)
Tutorials Arena
10/17/2024
12:37
Learn Programming Technique C to Master Skills - Fourth Program of Array
Tutorials Arena
10/20/2024
3:52
Learn Programming Technique C to Master Skills - Second Program of Loop (Flow Chart)
Tutorials Arena
10/17/2024
4:14
Learn Programming Technique C to Master Skills - Explanation of Second Program
Tutorials Arena
10/8/2024
7:35
Learn Programming Technique C to MasterĀ Skills - Fourth Program of Function
Tutorials Arena
11/3/2024
5:27
Learn Programming Technique C to MasterĀ Skills - Sixth Program of Function
Tutorials Arena
11/6/2024
3:51
Learn Programming Technique C to Master Skills - First Program of Loop (Flowchart)
Tutorials Arena
10/13/2024