Answer:
A "For" Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number
Explanation:
please mark me brainliest
In programming, a loop is used to repeat a block of code until the specified condition is met.
C programming has three types of loops:
1. for loop
2. while loop
3. do...while loop
We will learn about for loop in this tutorial. In the next tutorial, we will learn about while and do...while loop.
Program to calculate the sum of first n natural numbers
Positive integers 1,2,3...n are known as natural numbers
#include <stdio.h>
int main()
{
int num, count, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &num);
// for loop terminates when num is less than count
for(count = 1; count <= num; ++count)
sum += count;
}
printf("Sum = %d", sum);
return 0;
Copyright © 2024 EHUB.TIPS team's - All rights reserved.
Answers & Comments
Answer:
A "For" Loop is used to repeat a specific block of code a known number of times. For example, if we want to check the grade of every student in the class, we loop from 1 to that number
Explanation:
please mark me brainliest
Answer:
In programming, a loop is used to repeat a block of code until the specified condition is met.
C programming has three types of loops:
1. for loop
2. while loop
3. do...while loop
We will learn about for loop in this tutorial. In the next tutorial, we will learn about while and do...while loop.
Explanation:
Program to calculate the sum of first n natural numbers
Positive integers 1,2,3...n are known as natural numbers
#include <stdio.h>
int main()
{
int num, count, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &num);
// for loop terminates when num is less than count
for(count = 1; count <= num; ++count)
{
sum += count;
}
printf("Sum = %d", sum);
return 0;
}