Login

    C Command Line Tutorial 6 – Code indentation, increment/decrement operators, do-while and for loops, and more

    C Command Line Tutorial 6 – Code indentation, increment/decrement operators, do-while and for loops, and moreWe have covered a total of 5 C programming tutorials so far. Each tutorial focused on something specific. In process of remaining close to the topic, some generic concepts remained untouched. Some of those concepts we’ll be discussing here in this tutorial. So let’s begin.1. Code indentationYou should always properly indent your code. For starters, indentation is a practice where-in you put spaces/tabs/newlines to make the code look more readable. Usually, lines of code associated with

    Read More »

    Linux C Programming Tutorial Part 7: Arrays

    Linux C Programming Tutorial Part 7: ArraysSo we have already discussed the concept of variables in C programming (here and here). To quickly refresh, a variable is something which can hold a value of a particular type – it could be an integer, character, or even floating point. However, there’s one limitation of variables: they can only hold a single value at any given time.This means if you want to hold several values, you’ll have to deal with equal number of variables. For example, if you want a program to accept 10 integer values from user and then output them, then either you’ll write it

    Read More »

    Linux C Programming Tutorial Part 8 – Call by Value Vs Call by Pointer/Address

    Linux C Programming Tutorial Part 8 – Call by Value Vs Call by Pointer/AddressIn our first part of this ongoing tutorial series, we discussed briefly about functions, including their declaration and body. What we didn’t discuss at that time was the multiple ways in which functions are called. Here, in this tutorial, we will quickly discuss the ways that exist.In C language, you can call a function in a couple of ways: call by value and call by pointer or address. Let’s discuss both these concepts with some easy to understand examples.Let’s say you want to write a program that swaps two values.

    Read More »

    Linux C Programming Tutorial Part 9 : Strings

    Linux C Programming Tutorial Part 9 : StringsIn this ongoing C programming tutorial series, we have already touched upon the concept of character arrays. Closely related to character arrays is the concept of strings, which we’ll be discussing here.A string differs from a character array in one major area – it is terminated by a Null character ‘\0’. There is no such terminating character in a charcter array. The following piece of code shows some ways in which a string can be defined:#include int main(){ char str[] = “string”; char str1[] = {s,t,r,i,n,g,\0}; char str2[10] = “string”; c

    Read More »

    Linux C Programming Tutorial Part 10 – Variable Scopes

    Linux C Programming Tutorial Part 10 – Variable ScopesIf you are following our C programming tutorial series, you should be aware of the concept of variables. While we’ve discussed the basics of variables, there’s another important aspect related to variables that we’ll be discussing here: scope of variables. Let’s start with the swapping values code that we used in one of our previous tutorials:#include void swap (int val1, int val2){ int temp = 0; temp = val1; val1 = val2; val2 = temp; printf(“\nSwapped values are: %d and %d”, val1,val2);}int main(){ int a=0, b=0; printf(“Enter t

    Read More »

    Linux C Programming Tutorial Part 11 – Arithmetic, Relational, and Logical operators

    Linux C Programming Tutorial Part 11 – Arithmetic, Relational, and Logical operatorsUp until now, in this C programming tutorial series, we have discussed basic things like functions, arrays, variables, and more. Continuing with the flow, in this tutorial, we will discuss another such basic concept: operators.As a beginner in C programming language, you’ll majorly deal with three kinds of operators: arithmetic, relational, and logical. Let’s begin with the airthmetic operators.There are essentially 5 types of arithmetic operators in C: +, -, *, /, and %. While +, -, and / are self-explanatory,

    Read More »

    Linux C Programming Tutorial Part 12 – Assignment Operators and Conditional Expressions

    Linux C Programming Tutorial Part 12 – Assignment Operators and Conditional ExpressionsIn this ongoing C programming tutorial series, we have already discussed some of the basic stuff like arithmetic, logical, and relational operators as well as conditional loops like ‘if’ and ‘while’. Adding upon that, this tutorial will focus on assignment operators (other than =) and conditional expressions.Let’s start with assignment operators. If you have created basic C programs until now (which I am sure you would have especially after following our tutorial series), there are high chances you’d have do

    Read More »

    Linux C Programming Tutorial Part 13 – Bitwise Operators (Basics)

    Linux C Programming Tutorial Part 13 – Bitwise Operators (Basics)Up until now in this ongoing C programming tutorial series, we have discussed multiple kinds of operators, like arithmetic, logical, relational, and assignment. However, there’s another kind of operators that are very integral to the C programming language. We are talking about bitwise operators.As you might already know by now, every variable you use in your C program is stored in the form of bytes in memory. Further, these bytes are divided into 8 bits each. A bit can either be 1 or 0. For example, if a is a short integer (whic

    Read More »

    Linux C Programming Tutorial Part 14 – Bitwise operators practical examples

    Linux C Programming Tutorial Part 14 – Bitwise operators practical examplesIn one of our earlier articles, we discussed the basics of bitwise operators. I hope you went through that article and are now ready to witness and understand some practical usage examples of these operators. So without further ado, let’s begin.1. Swap values of two variablesI am sure you’d aware of the logic to swap values of two variables. It involves taking a third variable to temporarily store one value and then assign that value to one of the variables (whose original value has already been assigned to the other va

    Read More »

    Linux C Programming Tutorial Part 15 – 2’s Complement and Negative numbers

    Linux C Programming Tutorial Part 15 – 2’s Complement and Negative numbersUp until now, in this ongoing C programming tutorial series, we have discussed quite a few concepts, but missed a basic one. It’s about negative numbers. Yeah, though we briefly mentioned signed vs unsigned variables in one of our initial tutorials, we didn’t actually discuss how negative numbers are stored in memory.Well, that’s exactly what will be discussed in this tutorial. So without further ado, let’s start with the discussion.2’s complementBefore we begin with the explanation on negative numbers representation in

    Read More »