Tag Archives: Programming in C/C++

Comparing two integer values in C

 

Print char, int and float values in C

Visual Studio Code: ‘gcc’ is not recognized as an internal or external command, operable program or batch file.

  • Visual Studio Code – Main menu > View > Extensions > Install: C/C++ for Visual Studio Code and Code Runner
  • Download MinGW – Minimalist GNU for Windows (MinGW Installation Manager) > In “Basic setup” mark all packages to be installed > MiniGW Installation Manager Main menu > Installation > Apply changes > Copy the path where the \bin folder can be found e.g. C:\MiniGW\bin
  • Windows Desktop > This PC > right click > Properties > Advanced system settings > Environment variables > System variables > find the PATH variable and click Edit > click New and add the path C:\MiniGW\bin
  • Visual Studio Code – Main menu > File > Preferences > Settings > in the search box type “runner” > select the setting “Run in Terminal”.

Visual Studio Code Version: 1.53.2

Kelvin to Celsius Conversion in C

%.2f means print as a floating point with 2 decimals.

The output is:
Kelvin to Celsius Conversion Table in C

The sizeof Operator in C

The sizeof operator is used to determine the number of bytes required to store a value of a specific data type.

The output is :

The sizeof operator in C

IDE: Xcode Version 6.1.1

Compiler: Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)

Operating system: OS X Yosemite Version 10.10.1 (64-bit kernel)

Processor: Intel Core 2 Duo (64-bit processor).

Pre-increment and post-increment operators in C

a++ post increment (it increments the value of a after the operation is over)

++b  pre increment (it increments the value of b before the operation)

The output is:

Pre-increment and post-increment operators in C

Computing and displaying the cubes and the sums of cubes of the first 10 integers in C

The above program computes and displays cubes and sums of cubes of the first 10 integers. This program also illustrates the use of while loop.
running_sum=running_sum+CUBE(i1)
e.g. for i1=1 the running_sum=0+1=1, for i2=2 the running_sum=1+8=9

The output is:

Computing and displaying cubes and sums of cubes of the first 10 integers in C

Operation with integers in C++

The output is x=2015 and y=2019.

Hello World! in C++

The above code can be run for example in Eclipse IDE for C/C++ Developers or Xcode.