Learn Computer Programming In Tamil

Breaking

[தமிழில்] HTML & CSS Online Course

[தமிழில்] HTML & CSS Online Course
[தமிழில்] HTML & CSS Online Course

Saturday, April 25, 2020

C Program Structure In Tamil



c program structure

எல்லா c program-களிலும் இரண்டு முக்கிய பகுதி இருக்கும்.
1.Header
2.Main



Header
ஒவ்வொரு standard header file-ல் நிறைய inbuild function-யை கொண்டிருக்கும்.இந்த header file ஆனது .h என்ற extension உடன் முடிவு பெற்று இருக்கும்.
Ex:
stdio.h

stdio.h-ல் input மற்றும் output தொடர்பான அனைத்து function-களை உள்ளடக்கியிருக்கும்.printf(),scanf() function-கள் இந்த stdio.h என்ற header file-ல் தான் இருக்கும்.

Printf() function-யை பயன்படுத்தி c program-ல் இருந்து user-க்கு ஒரு message-யை காண்பிக்க முடியும்.

Scanf() function-யை பயன்படுத்தி user இடமிருந்து ஒரு input வாங்க முடியும்.அதனால் இந்த printf() மற்றும் scanf() function-யை நம் program-ல் பயன்படுத்த விரும்பினால் அதற்கு இந்த stdio.h என்ற header file-யை include செய்ய வேண்டும்.

Main Section:
main section-தான் program-ன் தொடக்க புள்ளி ஆகும்.நாம் program-யை எழுதிய பிறகு run செய்யும்பொழுது operating system ஆனது முதலில் main function-க்கு செல்லும் அங்கிருந்து execute ஆரம்பிக்கப்படும்.அங்கு ஒவ்வொரு statement-ஆக execute ஆகும். இந்த இரண்டு பகுதி சேர்ந்து தான் நமக்கு ஒரு முழுமையான c programming கிடைக்கின்றது.

#include<stdio.h>
int main()
{
printf(“Hello World”);
return 0;
}


#include<stdio.h>
#include என்பது ஒரு preprocessor directory ஆகும்.இதன் வேலை என்னவென்றால் angel bracket(<>) உள்ளே கொடுக்கின்ற file-யை source file-ல் include செய்யும்.இந்த program-ல் நாம் stdio.h என்ற file-யை கொடுத்து இருக்கின்றோம்.
stdio.h-ன் விரிவாக்கம் Standard Input Output Header File ஆகும்.இதனுள் printf(),scanf() function இருக்கின்றது.printf() user-க்கு ஒரு message-யை display செய்யும்,scanf() user-கிட்ட இருந்து input வாங்கவும் பயன்படுகிறது.இந்த functions-யை நம் program-ல் பயன்படுத்த வேண்டுமென்றால் stdio.h என்ற header file-யை include செய்ய வேண்டும்.அதனை நாம் include செய்த header file-யை #include என்கிற preprocessor directory நாம் எழுதுகின்ற தற்போதைய source file-ல் include பண்ணும்.

int main()
நாம் program-யை Run பண்ணும்பொழுது Operating System-ஆனது main function-ல் இருந்து தான் execution தொடங்கும்.இங்கு int என்பது main function ஒரு integer மதிப்பை return செய்யும் என்பதை குறிக்கின்றது.அந்த integer மதிப்பை program status என்று அழைப்பார்கள்.integer மதிப்பு zero-வாக இருந்தால் programming-ல் எந்தவொரு பிழையும் இல்லை அது நன்றாக வேலை செய்கின்றது என்று operating System தெரிந்து கொள்ளும். இதுவே zero-வை தவிர வேறு ஏதேனும் ஒரு நம்பர் வந்தால் programming-ல் பிழை இருக்கின்றது என்று Operating System தெரிந்து கொள்ளும்.

{ (open curly braces)
c programming block structured programming language என்று அழைப்பார்கள். open curly braces({) என்பது block-ன் தொடக்கத்தை குறிக்கின்றது.இங்கு கொடுக்கப்பட்டிருக்கும் open curly braces({) ஆனது main function-ன் தொடக்கத்தை குறிக்கின்றது.

printf(“Hello World”);
printf() function-யை பயன்படுத்தி user-க்கு ஒரு message-யை சொல்ல முடியும்.இந்த program execute ஆகும்போது printf()-ல் இருக்கும் hello world என்பது user-க்கு display செய்யப்படும்.

Printf() function-க்கு கடைசியாக semicolon(;) கொடுக்க வேண்டும் இல்லையென்றால் உங்கள் program-ல் error காண்பிக்கப்படும்.ஏனென்றால்,C program-ல் அனைத்து statement-ம் semi colon-ல் தான் முடிக்கப்பட்டுள்ளது.

return 0;
நாம் ஏற்கனவே இதை பற்றி பார்த்துள்ளோம்.அதாவது,main() function ஆனது programming status-யை operating system-க்கு அனுப்பப்படும்.program status மதிப்பு zero-வாக இருந்தால் success, Non-zero வாக இருந்தால் error என்று அர்த்தமாகும். அதாவது,main function-ல் இருந்து அனைத்து statement-களும் execute செய்யப்பட்டு கடைசியாக return 0; என்ற statement-க்கு வரும்.அப்படி return 0; என்ற statement-க்கு வந்தால் zero-வை return செய்துவிட்டு program terminate செய்து கொள்ளும்.
ஒருவேளை இடையில் எதாவது Error வந்தால் அங்கிருந்து ஒரு non-zero மதிப்பை return செய்துவிட்டு programming terminate செய்து கொள்ளும்.
எப்பொழுதெல்லாம் program ஆனது return 0; என்ற statement-க்கு வருகின்றதோ அப்பொழுதெல்லாம் programming-ல் எந்தவொரு error இல்லை என்று அர்த்தம் ஆகும்.


} (close curly braces)
நாம் open curly braces({) பயன்படுத்தி main function-ல் இருந்து ஆரம்பிக்கப்பட்டது.நமக்கு main function-ல் தேவையான வேலைகள் அனைத்தும் முடிக்கப்பட்டு விட்டது.இப்பொழுது நாம் close curly braces(}) போடுவதால் இத்துடன் main function முடிகிறது என்று அர்த்தம் ஆகும்.

No comments:

Post a Comment