## C Programming Tutorial – 27 – for Loop

GitHub – https://github.com/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/

• Views:123,043 views
• Rating:
• Categories:
• Tags:

koolkid54100 says:

why are you not starting the for loop with bacon = 0. When you discussed arrays you made it very clear that an array starts at 0 not 1.

notreever says:

Thank you so much m8!

Michael Knox says:

Thank you….you make a lot of sense

Thapelo mashapa says:

joo guys i really enjoy this video learning
#include

yerrapotu kiran says:

Thank you Bucky

Sanket Jain says:

#include
#include

int main()
{
int a, b, c;
printf(“Enter the three sides of the trianglen”);
scanf(” %d”, &a);
scanf(” %d”, &b);
scanf(” %d”, &c);

if(a == b == c){
printf(“The triangle is an equilateral trianglen”);
}
if(a == b != c){
printf(“The triangle is an isosceles trianglen”);
}
if(a != b != c){
printf(“The triangle is a scalene trianglen”);
}else{
printf(“Invalid Inputn”);
}
return 0;
}

What is wrong in this code for deciding which type of triangle is this.

Qasim Mustafa Ali says:

can’t see anything at all

Leverquin says:

is there anyway in codeblocks to see what included files stand for? like can i click somehow on and see what include?

Victor Damisa says:

pls guys what is the code for this program?

Write a program that accepts time in “seconds” format and prints it in minutes and seconds.
For example if you enter 89 it must print : 1:29 (you can use % modulus operator to compute
the remaining of a division)

Divij Arora says:

for (i=0; i<=10;i+1) { printf("%d", i); } why does this give "1" infinite times?

LoveTheCreator NotTheCreation says:

can’t really see what he’s typing….

Fake vids says:

Can’t see anything in mobile please post zoomed videos

william41017 says:

why this code

#include
#include

int main(){

int rep;

for(rep=1; rep=10; rep++){
printf(“testen”);
}

system(“pause”);
}
keeps repeating forever?

Daniel Austin says:

zaharouni1 says:

for repeating loop  while(1){code}; and for(:::);  are very usefull for programming micocontroller like avr,arm,pic…

ying tang says:

int main()
{
int banana;

for(banana==5; banana<=100;banana+=8){ printf("Banana is:%dn",banana); } return 0; } If I changed the banana=0 to banana==0, the first output is 2. And no matter what number I put after==, the first output is 2 too. Wondering why.

Enjoy this guys:
#include “stdio.h”
#include “stdlib.h”
#include “ctype.h”
#include “string.h”
#include “math.h”

int main()
{

int rows, columns;

for (rows = 1; rows < = 5; ++rows) { for (columns = 1; columns <= rows; ++columns) { printf("%d", columns); } printf("n"); } printf("n"); for (rows = 1; rows <= 5; ++rows) { for (columns = rows; columns > 0; –columns)
{
printf(“%d”, rows);
}

printf(“n”);
}

printf(“n”);

int i = 1;
for (rows = 1; rows <= 5; ++rows) { for (columns = 0; columns < rows; ++columns) { printf("%d", i); i++; } printf("n"); } return 0; }

Swapnil Achari says:

how to code for the sum of first 10 any numbers using for loop???

Aakash Thakor says:

Thank you for posting these tutorials, I am so lost in my intro to C class but these videos are helping me out!!

Rahul Sudhanaboina says:

Can we add more than three expressions in for loop?

Gouki says:

First!

Michael Moore says:

I was trying to do something similar to bacon += 8 in an array. I was wanting to add all the odd elements and all the even elements of an array. for instance:

int array[10];
int i, evens, odds, total;

for(i=0;i<10;i++)
scanf("%d", &array[i]);

for(i=0;i<10;i+2)
evens += array[i]

for(i=1;i<10;i+2)
odds += array[i]

total = odds - evens;

printf("%d", total);

It didn't work correctly. Does that code look ok or is there a better way to do it? I ended up doing it by using
for(i=0;i<10;i++ + i++)

but i don't like the way that code looks. Surely there is a better way to write it.

yezzzsir says:

still confused with int & char I tried copying this from memory and included the “&” by mistake and got a funny result? I thought you had to include this for anything other than a string? please advise.

le00 says:

int=hi
for(hi=0; hi<2; hi++ )
printf("hi")