for loops c code example
Example 1: loops in c
#include <stdio.h>
int main() {
int i;
for (i = 1; i < 11; ++i)
{
printf("%d ", i);
}
return 0;
}
Example 2: for loop c
for(int i = 0; i<n ;i++)
{
}
Example 3: c for
int i;
for(i=0; i<5; i++)
{
printf("Nummber %d\n", i+1);
}
Example 4: for loop in c
int i;
for (i = 0; i < n; ++i) {
}
Example 5: for loop in c
#include <stdio.h>
int main()
{
int num, count, sum = 0;
printf("Enter a positive integer: ");
scanf("%d", &num);
for(count = 1; count <= num; ++count)
{
sum += count;
}
printf("Sum = %d", sum);
return 0;
}