Saturday, 3 December 2016

C Language Syntax Rules

C Language Syntax Rules

C language syntax specify rules for sequence of characters to be written in C language. 
The rule specify how character sequence will be grouped together to form tokens. 
A smallest individual unit in c program is known as C Tokens. Tokens are either keyword, identifier, constant, variable or any symbol 
which has some meaning in C language. A C program can also be called as collection of various tokens.

Example of C tokens,


1 int
2 Semicolon (;)





Comments


Comments are simple text in your C program that increases readability of programs. Compiler ignore anything written as comment in your program.

Example of comments :

Single line Comment
//This is a comment

Single line Comment
/*This is a comment*/

Multi line Comment
/*This is a long 
and valid comment*/

Wrong Syntax
//this is not
  a valid comment


Some basic syntax rule for C program


  1. C is a case sensitive language so all C instructions must be written in lower case letter.
  2. All C statement must be end with a semicolon.
  3. Whitespace is used in C to describe blanks and tabs.
  4. Whitespace is required between keywords and identifiers

C Input output function

C programming language provides many of the built-in functions to read given input and write data on screen, printer or in any file.


1 scanf() and printf() functions


#include<stdio.h>
#include<conio.h>
void main()
{
 int i;
 printf("Enter any value");
 scanf("%d",&i);
 printf( "\nYou entered:= %d",i);
 getch();
}

When you will compile the above code, it will ask you to enter a value. When you will enter the value  , it will display the value you have entered.

2 getchar() & putchar() functions


#include <stdio.h>
#include <conio.h>
void main( )
{
 int m;
 printf("Enter a character");
 m=getchar();
 putchar(m);
 getch();
}

The getchar() function reads a character from the terminal and returns it as an integer. This function reads only single character at a time. You can use this method in the loop in case you want to read more than one characters. The putchar() function prints the character passed to it on the screen and returns the same character. This function puts only single character at a time. In case you want to display more than one characters, use putchar() method in the loop.
When you will compile the above code,it will ask you to enter a value. When you will enter the value, it will display the value you have entered.

3 gets() & puts() functions


#include<stdio.h>
#include<conio.h>
void main()
{
 char s[100];
 printf("Enter any string");
 gets(s);
 puts(s);
 getch();
}

The gets() function reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF (end of file). The puts() function writes the string s and a trailing newline to stdout.
When you will compile the above code,it will ask you to enter a string. When you will enter the string, it will display the value you have entered.

Wednesday, 14 September 2016

Explanation of First C Program:-

--------------------------------------------------------------------------------

1) #include<stdio.h>
2) #include<conio.h>

3) void main()

4) {
5) int a = 190;

6) clrscr();

7) printf("%d\n",a);

8) getch();

9) }


Explanation:-

--------------------------------------------------------------------------------

Line 1: 

"stdio.h" is a header file. It is the abbreviation of Standard Input Output Header File. It contains the prototypes of printf() and scanf() functions.

Line 2: 
"conio.h" is a header file. It is the abbreviation of Console Input Output Header File. It contains the prototypes of clrscr() and getch() functions.

Line 3: 
"void main()" =>  is the main function. Every C program has only and only one such function.

Line 4 and Line 9:
 "{" =>  is called opening brace and "}" is called the closing brace. Between them, we write the statements of the function.They are used to enclose the statements of loops and conditional statements.
 
Line 5:
"int a;" =>  declares 'a' as a variable of integer data type, with a
value of 190. int is short word for integer. Notice the semi colon at the end, it is important.


Line 6: 
"clrscr();" => is the short for "clear screen". It is used to clear the screen.

Line 7: 
"printf("%d\n",a);" => This line uses printf function. The 'f' in printf stands for 'format'. %d is the format string to print integers.The 'a' after the comma is the variable 'a' which we declared in line 5. \n is an escape sequence used to insert a new line.

Line 8:
 "getch()" => This line uses getch() function. 'getch()' stands for get character. It is a console oriented function.

Tuesday, 13 September 2016

Start Up With C :-


You can Build your first program by just following These

 Steps : -


When you want to program in C Language, you will have to fulfill certain minimum requirements so that you can build your programs without unexpected results. Here, we give you the list of those minimum requirements!

1) A Personal Computer or a Laptop on which you will make your programs.

2) A C Compiler to compile the programs you make.

*There are no minimum hardware requirements.


Choose the compiler carefully, as not all compilers are suitable on all platforms. Platform here means your Operating System.

Even a text editor is preferred to write programs in C by some programmers. They type the code in a text file and then compile that code by a compiler. 
But today you don't need to code and compile at two separate locations

Download C compiler Here :


After you install the application, install it.

Open it

Click on 'File' > 'New'.

Start Coding !

To compile the program, press Alt + F9.

To run the program (which is possible if you did not make any errors.) press 
Ctrl+F9.

Saturday, 10 September 2016

All Relational Operations in Php Using If-else statements



output :


Friday, 9 September 2016

Introduction and Benefits of C Programming Language :-


Introduction : -


                  C is a high level structured oriented programming language, used in general purpose programming language, developed by Dennis Ritchie at AT&T bell labs.
 
      It was developed between the years 1969 and 1973.
 
 
 => In 1988, the ANSI (American National Standards Institute) has formalized the C language.
 
 => C was invented to write UNIX operating system.
 
 => C is a successor of B CPL ('Basic Combined Programming Language') called the B Language.
 
 => Linux Operating System, PHP and MySQL is written in C.
 
 => C has been written in assembly language.
 
 
 Why should I learn C?
 
 :- One of the early programming languages.
 
 :- Still the best programming language to learn quickly.
 
 :- C language is reliable, simple and easy to use.
 
 :- C language is structured language.
 
 :- Modern programming concepts are based on C.
 
 :- It can be compiled on a variety of platforms.
 
 :- Universities prefer to add C programming language in their courseware.

Friday, 2 September 2016

All Relational Operations in Java Using If-else statements



output :