Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,808 members, 7,810,108 topics. Date: Friday, 26 April 2024 at 08:53 PM

Lets Learn C - Programming (3) - Nairaland

Nairaland Forum / Science/Technology / Programming / Lets Learn C (9189 Views)

Is It Possible To Learn C++ In A Year? / Learn C++ Programming Language In Few Days / Lets Learn Programming From Bignners To Expert Through Tutorials (2) (3) (4)

(1) (2) (3) (4) (5) (Reply) (Go Down)

Re: Lets Learn C by romme2u: 2:43am On Jul 26, 2016
stack1:


hmm, ok

well in this case, the next post's would go over C's operators, control structures and loops, i had already discussed integer and char data type, that should do for now till we go into advanced stuff like structures and arrays/pointers

that is cool
Re: Lets Learn C by stack1(m): 2:43am On Jul 26, 2016
lets see another basic for loop usage...
Re: Lets Learn C by stack1(m): 2:53am On Jul 26, 2016
This code is similar to the last except the updateStament counts downwards



#include <stdio.h>
int main(void)
{


int secs;

printf("Count down started!\n" );

for (secs = 5; secs > 0; secs--){
printf("\t %d !\n", secs);

}
printf("We have ignition!\n" );
getchar();
}



Here is the output:
Count down started

5 !
4 !
3 !
2 !
1 !
We have ignition!

the statement secs-- is a post-decrement (as opposed to increment) and it decreases the value of variable sec by one after each execution of the loop body
Re: Lets Learn C by stack1(m): 2:56am On Jul 26, 2016
... a few more for loop examples
Re: Lets Learn C by stack1(m): 3:04am On Jul 26, 2016
By the way my good people them, when learning any form of programming, don't rely only on the source you are learning form, learn to digg deeper on your own (Google is your friend here), how fast and well you'll learn truly depends on how enthusiastic u are and how far you are willing to research further on your own
Re: Lets Learn C by Nobody: 6:25am On Jul 26, 2016
@op, keep up the good work, am using this to refreshy my rusty memory.
Re: Lets Learn C by bestiyke(m): 6:32am On Jul 26, 2016
stack1:


aiit, but em, sorry o, u using *dear in that sentence, i be male o
I don't know what you mean. My heart is as clear as crystal. I'm only delighted by your tutorial posts. I don't know when *'dear' became gender sensitive. We Nigerians and our myopic reasoning. Sorry anyway if it is a wrong word.
Re: Lets Learn C by Nobody: 7:35am On Jul 26, 2016
bestiyke:
I don't know what you mean. My heart is as clear as crystal. I'm only delighted by your tutorial posts. I don't know when *'dear' became gender sensitive. We Nigerians and our myopic reasoning. Sorry anyway if it is a wrong word.
Oh, you are not even a Nigerian, no wonder. If a man calls me DEAR in the real world, I would have done a 70-moves-kata on his head before he explains himself.
Re: Lets Learn C by stack1(m): 7:51am On Jul 26, 2016
dhtml18:

Oh, you are not even a Nigerian, no wonder. If a man calls me DEAR in the real world, I would have done a 70-moves-kata on his head before he explains himself.

LOL, i thought i was only joking anyway.. smiley cool
Re: Lets Learn C by stack1(m): 7:53am On Jul 26, 2016
bestiyke:
I don't know what you mean. My heart is as clear as crystal. I'm only delighted by your tutorial posts. I don't know when *'dear' became gender sensitive. We Nigerians and our myopic reasoning. Sorry anyway if it is a wrong word.
Myopic?, bro, me just dey catch fun nah. shu, but then again its not a standard way guys address each other for our 9ja
Re: Lets Learn C by stack1(m): 7:55am On Jul 26, 2016
I might or might not be posting much for the next few days, as i got some waka waka to do, please if anyone has got questions up to this point??
Re: Lets Learn C by bestiyke(m): 9:20am On Jul 26, 2016
stack1:

Myopic?, its not a standard way guys address each other for our 9ja
Apology!!! Some how I was disappointed because the comment was beyond my imagination.
Re: Lets Learn C by bestiyke(m): 9:25am On Jul 26, 2016
dhtml18:

Oh, you are not even a Nigerian, no wonder. If a man calls me DEAR in the real world, I would have done a 70-moves-kata on his head before he explains himself.
I don't have a word for u because everyone on Nairaland/programming session knows your character. I still respect you person anyway.
Re: Lets Learn C by furthest(m): 9:38am On Jul 26, 2016
please every1 I need a complier..I can't find any online..please help a bro here
Re: Lets Learn C by stack1(m): 9:44am On Jul 26, 2016
bestiyke:
I don't have a word for u because everyone on Nairaland/programming session knows your character. I still respect you person anyway.

guys can we end this matter
Re: Lets Learn C by stack1(m): 9:48am On Jul 26, 2016
furthest:
please every1 I need a complier..I can't find any online..please help a bro here


bro i pasted the links for both 32bit and 64bit GCC compilers on page 1 and inatructions on setting them upe with code blocks, aanyway here are the links again


if you are on 32bit windows get this file here
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win32_6.1.1-20160715.7z/download

and for 64bit systems get this
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win64_6.1.1-20160715.7z/download
Re: Lets Learn C by furthest(m): 9:50am On Jul 26, 2016
stack1:


bro i pasted the links for both 32bit and 64bit GCC compilers on page 1 and inatructions on setting them upe with code blocks, aanyway here are the links again


if you are on 32bit windows get this file here
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win32_6.1.1-20160715.7z/download

and for 64bit systems get this
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win64_6.1.1-20160715.7z/download
thanks bro
Re: Lets Learn C by furthest(m): 1:27pm On Jul 26, 2016
furthest:
thanks bro
bro i cant find it. i installed it in c directory
Re: Lets Learn C by furthest(m): 1:42pm On Jul 26, 2016
please how do i compile?
Re: Lets Learn C by stack1(m): 2:21pm On Jul 26, 2016
the GCC compiler package in the link i pasted would download as a 7z archive so you'll need a tool such as WinRar (http://www.rarlab.com/download.htm) or 7-zip (http://www.7-zip.org/download.html) to extract the contents, after extracting ( i only recommend extracting to the root of your C: drive, any other location should do) you then setup Codeblocks to use the GCC compilers from the Settings->Compilers menu

Then you can directly compile from the build menu
Re: Lets Learn C by 2mNaira: 10:11pm On Jul 28, 2016
stack1:
ok, before i go into the details of the line counting program, can anyone provide us summary of how it works?


I wanted to ignore this thread altigether,but decided against it.Why dont u intrioduce operators(like addition etc) and control statements (while,for goto and return ) to us first. If pple are already graspg it as it is then no problem.
Re: Lets Learn C by Nobody: 10:28pm On Jul 28, 2016
is alright, join the fun
Re: Lets Learn C by stack1(m): 11:13pm On Jul 28, 2016
mnairaland:



I wanted to ignore this thread altigether,but decided against it.Why dont u intrioduce operators(like addition etc) and control statements (while,for goto and return ) to us first. If pple are already graspg it as it is then no problem.

am already doind that bro, see the last few post's, yeah i know i shoulld have started with d basics,make una no vex, currently on for loops, and sorry to everyone for not posting anything on-topic for a feew dayz now bn away from my system and i no fit type long post on phone, would continue tommorow (if Nepa coporates that is)
Re: Lets Learn C by 2mNaira: 1:59am On Jul 29, 2016
dhtml18:
is alright, join the fun

I suspect that this comment is directed at me.If it is,I'd say that I made that comment just to steer him in d right direction.have been programmg in C/C++ for about a decade. I did not want to sound like an intimidating Guru.Although its a good job he is doing here, I still have ignore the thread.Its not for me.
Re: Lets Learn C by Nobody: 7:00am On Jul 29, 2016
^^^it matters not whether you are a guru or not, just have fun and enjoy the thread, that is why i am here to, to encourage the OP.
Re: Lets Learn C by stack1(m): 9:33am On Jul 29, 2016
dhtml18:
^^^it matters not whether you are a guru or not, just have fun and enjoy the thread, that is why i am here to, to encourage the OP.

dhtml18 grin
Re: Lets Learn C by Nobody: 11:07am On Jul 29, 2016
stack1:

dhtml18 grin
dont mind that boy, he is an E-TROLL.
Re: Lets Learn C by stack1(m): 8:25am On Jul 30, 2016
The update statement in for loops do not need to be increased/decreased by one, any arbitrary number or expression would do


#include <stdio.h>
int main(void)
{
int n; // count by 13's from 2
for (n = 2; n < 60; n = n + 13)
printf("%d \n", n);

getchar();
return 0;
}


This would increase n by 13 during each cycle, printing the following:
2
15
28
41
54


In the above program, the variable n is initialized with the value 2, and then the loop checks runs only if the value of variable n is less than 60, and then after each run of the loop n is increased by 13, this process continues till the test condition n < 60 fails and the loop is then terminated
Re: Lets Learn C by stack1(m): 8:34am On Jul 30, 2016
Here we show that more complex expressions can be used for any of the values in a for loop


#include <stdio.h>
int main(void)
{
int x;
int y = 55;
for (x = 1; y <= 75; y = (++x * 5) + 50)
printf("%d \t %d\n", x, y);

getchar();
return 0;
}


This loop prints the values of x and of the algebraic expression ++x * 5 + 50 . The
output looks like this:
1 55
2 60
3 65
4 70
5 75

While we haven't discussed operator in-depth the expression (++x * 5) + 50 should be trivial to comprehend
The variable (x) is first initialized to 1 in the loop's initialization statement. Then in the update statement it is per-incremented by one then multiplied by five, and the result added to 50
Re: Lets Learn C by stack1(m): 8:40am On Jul 30, 2016
In the last example you'll notice the for loop's body isn't enclosed in braces {} generally if the body of a loop is contained wholly one one line the braces can be excluded
Re: Lets Learn C by stack1(m): 8:42am On Jul 30, 2016
[size=16pt]while[/size] loops
Re: Lets Learn C by stack1(m): 8:51am On Jul 30, 2016
The while loop is another general purpose loop, and is renowned for its compactness and ease in handling complex loop expressions

the basic form of the while loop is



while ( control-expression )
statement



The control-expression or statement parts could be simple or complex statements
The basic operation of the while is straight forward

-- the loops control-expression is evaluated first and if the result of the evaluation is non-zero/non-false the statement contained in the loop's body is executed, this process is repeated until the control-expression fails

(1) (2) (3) (4) (5) (Reply)

An Introduction To Programming Using C / How Do You Get A CEH / Pentesting Job In Nigeria? / Android Quiz Application With Json Parser, Php And Mysql Database

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 37
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.