Monday, June 24, 2019

Comments in C


Comments in C language are used to provide information about lines of code. It is widely used for documenting code. There are 2 types of comments in the C language.
·       Single Line Comments
·       Multi-Line Comments

Single Line Comments
//printing information 

Mult Line Comments
/*printing information  
      Multi-Line Comment*/ 

Operators in C


An operator is simply a symbol that is used to perform operations. There can be many types of operations like arithmetic, logical, bitwise, etc.

There are following types of operators to perform different types of operations in C language.

·       Arithmetic Operators
·       Relational Operators
·       Shift Operators
·       Logical Operators
·       Bitwise Operators
·       Ternary or Conditional Operators
·       Assignment Operator
·       Misc Operator

Data Types in C


A data type specifies the type of data that a variable can store such as integer, floating, character, etc.

There are the following data types in C language.

Types
Data Types
Basic Data Type
int, char, float, double
Derived Data Type
array, pointer, structure, union
Enumeration Data Type
enum
Void Data Type
void

Variables in C


A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times.

It is a way to represent memory location through symbol so that it can be easily identified.

Let's see the syntax to declare a variable:
·       int a; 
·       float b; 
·       char c;

int a=10, b=20;      //declaring 2 variable of integer type 
float f=20.8; 
char c='A'; 

Valid variable names:
int a; 
int _ab; 
int a30;

Invalid variable names:
int 2; 
int a b; 
int long; 

Types of Variables in C:
·       local variable
·       global variable
·       static variable
·       automatic variable
·       external variable

Sunday, June 23, 2019

printf() and scanf() in C


The printf() and scanf() functions are used for input and output in C language. Both functions are inbuilt library functions, defined in stdio.h (header file).

printf() function
The printf() function is used for output. It prints the given statement to the console.

Printf(“Welcome To The Aryabhatta Institute”);
Printf(“format string”, argument_list);

The format string can be %d (integer), %c (character), %s (string), %f (float) etc.

scanf() function
The scanf() function is used for input. It reads the input data from the console.
scanf(“format string”, argument_list);

First C program



#include<stdio.h>
int main()
{
          Printf(“Welcome To The Aryabhatta Institute”);
          Return 0;
}
Here, # - is a preprocessor directive
Here, <stdio.h> - is include the standard input output library function
Here, int main – is a function which is the entry point of every program in c language
Here, printf() – is used to print data on the console
Here, return 0 – return execution status 0 for successful execution and 1 for unsuccessful execution.

How to install C


There are many compilers available for c and c++. You need to download any one. Here, we are going to use Turbo C++. It will work for both C and C++. To install the Turbo C software, you need to follow following steps.

Download Turbo C++
Create turboc directory inside c drive and extract the tc3.zip inside c:\turboc
Double click on install.exe file
Click on the tc application file located inside c:\TC\BIN to write the c program