Wa0015.
Wa0015.
Seat No:B23161006047
Deptt: International relations
Class: 2nd year (3rd semester)
Assignment #3 C program
times until a specific condition satisfies. Simply we can say that it is the
process of repeatedly
executing a block of code. The term looping is also used for iteration. Further
the concept of
iteration is that it allows you to automate repetitive tasks, Making your code
more efficient and
concise.instead of writing the same lines of code multiple times, you can use
a loop (iteration) to execute them repeatedly.
2While loop
FOR LOOP
while loop:
The term condition controlled is also used for while loop and it is UJsed when
you need to repeat a block of code as long as a certain condition remains
true.
The condition is checked before each iteration and the iteration should
continue as long as certain condition is met.
Reading input from the users untill a specific value is entered. do-
while loop:
It is Similar to the while loop, but it guarantees that the code block will
execute at least once.
Example
Iteration is essential for tasks like processing arrays, reading files, and
performing calculations
repeatedly.
Properly managing loop conditions is important to avoid infinite loops.
Repetition is a key aspect of programming, and the C language for loop is a powerful tool to
handle it effectively. When you need to perform a task multiple times, whether it's iterating
through an array,generating patterns, or summing up numbers, the for loop in C offers a
concise and structured approach.
By allowing you to control the initialization, condition, and update of variables in one place,
it
simplifies repetitive operations. In this post, we'll explore everything about the for
loop,including how it works, its syntax,real-life applications, and examples to help
Like other loops, for loop in C programming runs a block of code several times until a
condition
is met. More completely, for is a statement in the C programming language that will
repeat a
block of code a specific number of times.The loop consists of three main parts:initialization(
efficient.
1.Initialization:
This step initializes the loop control variable (e.g., int i= 0). It runs only once,at the start of
the loop.
2.Condition:
The condition is a logical expression that determines whether the loop should cont
4. Loop Body:
It contains the statements to execute repeatedly. The loop body runs every time the
condition evaluates to true.The code enclosed within the curly braces {} is the loop body.
Q3: Write a c program for data analysis in international relations that calculates
the average trade value fromuser input.
Solution: #include
<stdio.h>
// Display the average trade value printf("\nThe average trade value across %d
"Student");
return 0;
}了
Output Results:
Enter the number of countries involved in the trade:5
Visual Ouput: