Language Foundations / Logical Operators (C)

Continuing on with learning C, I have recently completed the C: Language Foundations course via edX in conjunction with Dartmouth and IMT.

C: Language Foundations has the following learning outcomes:

  • Use logical conditions to control the flow of a program via branch statements (if-else), repetition (for or while loop) and nesting of these structures
  • Create and modify arrays to store integer and floating point numbers and explain how arrays are organised in memory
  • Create null-terminated arrays of characters to store and modify strings (of characters)
  • Sort and search arrays of numbers and characters using bubble sort, selection sort, linear search and bisection

As with the previous C course I’m proud to announce I’ve earned a passing grade in the course. I’m using this blog post to store some of my notes.

if Command

The if command in C is used as the command followed by the arguments with brackets. For example:


printf(“4 is greater than 3”);


else Command

The else command in C is used in conjunction with the if command in a similar method. For example:


printf(“4 is less than 3…wrong!”);

} else {

printf(“4 is greater than 3!”);


else if Command

else and if can be used together to chain several possible scenarios. For example:

if (10 < 10){

printf(“10 is less than 10?”);

} else if (10 > 10){

printf(“10 is greater than 10?”);

} else if (10 == 10){

printf(“yep, 10 is equal to 10”);

} else {

printf(“One of the above should be true….”);


while Command

The while command is used similarly to the if command with the argument going in brackets after the command. For example:

while (budget != 0)
budget = budget -1;
scanf(“more budget used”);
printf(“Budget spent!”);


When using commands with C the following are operators that are possible to use:

< Less Than

<= Less Than or Equal To

> Greater Than

>= Greater Than or Equal To

== Equal To

!= Not Equal To

|| Or

&& And

I’ve had fun completing C Programming: Language Foundations and learning more C.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.