Your First Program C - Program Structure


so when we install GCC on Windows, then we  need to install MinGW. so  install MinGW,.
 MinGW installation program, which should be named MinGW-<version>.exe.

when we installing  Min GW, at  a minimum, so you have to necessary to install GCC -core, g++ binutils, and the MinGW.

Add the bin subdirectory of your MinGW installation to your PATHenvironment variable, so that you can specify these tools on the command line by their simple names.


After the installation is complete, you will be able to run gcc, g++,


after  GNU tools from the windows command line.




                                            C- PROGRAM STRUCTURE

In this article, you'll learn about structures in C programming; what is it, how to define it and use it in your program.

Structure is a collection of variables of different types under a single name.

For example: You want to store some information about a person: his/her name, Membership  number and salary. You can easily create different variables name, cit No, salary to store these information separately. so this is also called program.




Before we study the basic building blocks of the C programming language, let us look at a bare  minimum C program structure  that why  we can take it as a reference in the  in next  chapters.
  

Your First Program

Hello World example

C program basically consists of the following:-
1) Commands/ pre-processor directive 
 2) simple C functiom
 3) variable
 4)comments to your programs
                                    
Now that you've seen the compiler in action it's time for you to write your very own first C program. You can probably guess what it's going to be - the program that everyone writes just to check they understand the very, very, very basics of what is going on in a new language.


 All your first program is going to do is print the message "Hello World" on the screen.

The program is a short one, to say the least. Here it is:



The program is a short one, to say the least. Here it is:



Let us look at a simple code that would print the words "Hello World" −
#include <stdio.h>

int main() {
   /* my first program in C */
   printf("Hello, World! \n");
   
   return 0;
}



The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going 
The first line is the standard start for all C programs - main(). After this comes the program's 
only instruction enclosed in curly brackets {}. The curly brackets mark the start and end of the list of instructions that make up the program - in this case just one instruction.


thee next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.


Notice the semicolon marking the end of the instruction. You might as well get into the habit of ending every C instruction with a semicolon - it will save you a lot of trouble! Also notice that the semicolon marks the end of an instruction - it isn't a separator as is the custom in other languages

If you're puzzled about why the curly brackets are on separate lines I'd better tell you that it's just a layout convention to help you spot matching brackets. C is very unfussy about the way you lay it out. For example, you could enter the Hello World program as:
main(){printf("Hello World\n");}



The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen.



The next line return 0; terminates the main() function and returns the value 0.
                                   






































































Comments

Popular posts from this blog

C LANGUAGE

How to do a clean install of mac OS