A program is a set of instructions that a computer follows in order to perform a specific task. There are different types of programming languages such as BASIC, Pascal, C, Java, Ruby, Python, etc...On this site, we will see about the C program.
C is a general-purpose, procedural computer programming language. It is an ANSI/ISO standard and powerful programming language for developing real-time applications. It was invented by Dennis Ritchie at the bell laboratories in 1972. It is the most widely used language and it is the basic for all programming languages, all other programming languages were directly (or) indirectly derived from C.
Rules for writing a c program:
* Each instruction in the c program is written as a separate statement.
* The statements in the program must appear in the same order in which we wish them to be executed unless the logic of the program demands a deliberate jump or transfer of control to a statement that is out of sequence.
* Blank spaces may be inserted between two words to improve the readability of the statement.
* All syntax should be entered in small case letters.
* Every c statement must end with a ( ; ) thus ( ; ) act as a Statement terminator.
* There is no specific rule for the position at which the statement is to be written. that's why it is often called a free-form language.
we are going to see how to write a simple program using a C programming language as well as we are going to see some basic definitions. suppose if your a beginner in programing language you have to know that some definition, you didn't know that some definition you couldn't write the program.so now in this site first we focus to learn some data types and some related concepts we are going to see now.
- int (integer a whole number)
- float(floating point a number which is a fractional point)
- double(double precision floating point)
- char(single character)
#include<stdio.h> #include<conio.h> void main() {
printf("hello world"); getch(); }
|
now how its execute our program we will see above the contents
#include<stdio.h> - its called header file "stdio.h" standard file
int main() -its the main function its contains int data type only, you cant store any float or something .when you using the main function any place you should put curly brackets {},
then next you should write your code.
printf()- which means it is print your value.
return 0- return the value of your program
one thing you should know that when you using int main()
At that time you have to put return value on your insides curly bracket.
some times we are using void main().
void main()-void main which means we can give any data types in your program. because it contains an only empty value. you can give any value.
when you using void main() in the last statement you should give getch();
getch(); - getch means it gives your output on your console suppose if you didn't give getch(); at the last of ur statement your program won't run, if your program has right also its will not give your program output.
some basic important syntax :
these are the basic syntax for main startcture. first be familiar with these sysntax then move further ways



No comments:
Post a Comment