সি প্রোগ্রামিং: সংশোধিত সংস্করণের মধ্যে পার্থক্য

উইকিপিডিয়া, মুক্ত বিশ্বকোষ থেকে
বিষয়বস্তু বিয়োগ হয়েছে বিষয়বস্তু যোগ হয়েছে
Sabbir104 (আলোচনা | অবদান)
সম্পাদনা সারাংশ নেই
সম্পাদনা সারাংশ নেই
১২০ নং লাইন: ১২০ নং লাইন:
The C Standard Library is a reference for C programmers to help them in their projects related to system programming. All the C functions have been explained in a user-friendly way and they can be copied and pasted in your C projects.
The C Standard Library is a reference for C programmers to help them in their projects related to system programming. All the C functions have been explained in a user-friendly way and they can be copied and pasted in your C projects.
<br/>
<br/>

====C Library - <assert.h>====
The assert.h header file of the C Standard Library provides a macro called assert which can be used to verify assumptions made by the program and print a diagnostic message if this assumption is false.

The defined macro assert refers to another macro NDEBUG which is not a part of <assert.h>. If NDEBUG is defined as a macro name in the source file, at the point where <assert.h> is included, the assert macro is defined as follows −
<br/>
[[#define assert(ignore)((void)0)]]
<br/>
====C Library - <ctype.h>====
The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters.

All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.

All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not.
<br/>
===Library Functions :===
Following are the functions defined in the header ctype.h −
{{সূত্র তালিকা}}

== উদাহরণ কোড ==
== উদাহরণ কোড ==
সি প্রোগ্রামিং ভাষার উদাহরন :
সি প্রোগ্রামিং ভাষার উদাহরন :
১৪৬ নং লাইন: ১৬৫ নং লাইন:
<br/>
<br/>


====C Library - <assert.h>====
The assert.h header file of the C Standard Library provides a macro called assert which can be used to verify assumptions made by the program and print a diagnostic message if this assumption is false.

The defined macro assert refers to another macro NDEBUG which is not a part of <assert.h>. If NDEBUG is defined as a macro name in the source file, at the point where <assert.h> is included, the assert macro is defined as follows −
<br/>
[[#define assert(ignore)((void)0)]]
<br/>
====C Library - <ctype.h>====
The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters.

All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.

All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not.
<br/>
===Library Functions :===
Following are the functions defined in the header ctype.h −
{{সূত্র তালিকা}}


== ভেরিয়েবল সমূহ==
== ভেরিয়েবল সমূহ==

১২:৫৭, ৭ মার্চ ২০১৬ তারিখে সংশোধিত সংস্করণ

সি প্রোগ্রামিং ভাষা

সি ভাষার পরিচিতি :

ভূমিকা :

সি প্রোগ্রামিং
চিত্র:K&R C.jpg
দ্য সি প্রোগ্রামিং ল্যাঙ্গুয়েজ, ব্রায়ান কার্নিগানডেনিস রিচি-র লেখা মূল সংস্করণের প্রচ্ছদ; এই বইটি সুদীর্ঘ সময় ধরে ভাষাটির একটি অ-প্রমিত বিবরণ হিসেবে ধরা হত।
প্যারাডাইমনির্দেশমূলক (পদ্ধতিমূলক) সিস্টেম্‌স বাস্তবায়ন ভাষা
নকশাকারডেনিস রিচি
বিকাশকারীডেনিস রিচি এবং বেল ল্যাব্‌স
প্রথম প্রদর্শিত১৯৭২
টাইপিং পদ্ধতিস্থির, দুর্বল
মুখ্য বাস্তবায়নসমূহ
ক্ল্যাং, জিসিসি, মাইক্রোসফট ভিজুয়্যাল সি/সি++, বোরল্যান্ড সি, ওয়াটকম সি
যার দ্বারা প্রভাবিত
বি (বিসিপিএল, সিপিএল), অ্যালগল ৬৮, অ্যাসেম্বলি ভাষা
যাকে প্রভাবিত করেছে
অক, সি শেল, সি++, সি শার্প, অবজেক্টিভ সি, বিটসি, ডি, কনকারেন্ট সি, জাভা, জাভাস্ক্রিপ্ট, লিম্বো, পার্ল, পিএইচপি

সি একটি প্রোগ্রামিং ভাষা এটি একটি স্ট্রাকচারাল ল্যাঙ্গুয়েজ । এ ভাষায় ডাটার চেয়ে ফাংশনের গূরুত্ব বেশি ।। সি নির্মাণ করেন ডেনিস রিচি, বেল ল্যাবে ৭০এর দশকে কাজ করার সময়। ভাষাটি তৈরির প্রথম উদ্দেশ্য ছিল ইউনিক্স অপারেটিং সিস্টেম-এর কোড লেখায় এর ব্যবহার, কিন্তু অচিরেই এটি একটি বহুল ব্যবহৃত ভাষায় পরিণত হয়। সি++জাভা সহ পরিবর্তীকালের অনেক প্রোগ্রামিং ভাষার উপর সি'র গভীর প্রভাব পড়েছে। সি এর সবচেয়ে আকর্ষণীয় দিক হচ্ছে এর বহনযোগ্যতা। সি দিয়ে রচিত প্রোগ্রাম যেকোন অপাররেটিং সিস্টেমের কম্পিউটারে চালানো যায়। ৭০ এবং ৮০ দশকের দিকে সি এর জনপ্রিয়তা বাড়ার সাথে সাথে এর অনেকগুলো ভার্সন তৈরি হয়। ১৯৮৩ সালে আমেরিকান মাননিয়ন্ত্রক সংস্থা সি এর ১টি আদর্শ ভার্সন তৈরির জন্য কমিটি গঠন করে। দীর্ঘ ৬ বছর পরে ১৯৮৯ সালে সেই আদর্শ সি ভাষাটি তৈরি হয়, যা আমেরিকান মাননিয়ন্ত্রক সংস্থা সি (আনসি সি (ANSI C)) নামে পরিচিত। পরবর্তিতে আন্তর্জাতিক মাননিয়ন্ত্রক সংস্থা ১৯৯০ সালে সি এর এই আদর্শ ভার্সনটি গ্রহণ করে, যা সি৯০ নামে পরিচিত। মুলত "সি৮৯" এবং "সি৯০" একই ভাষা। যুগের প্রয়োজনে আন্তর্জাতিক মাননিয়ন্ত্রক সংস্থা ১৯৯৫ সালে এই সংস্করণকে বর্ধিত করে এবং পরবর্তিতে ১৯৯৯ সালে সম্পূর্ণ নতুন একটি সংস্করণ প্রকাশ করে যা সি৯৯ নামে পরিচিত। সর্বশেষ ২০১১ সালে সি প্রোগ্রামিং ল্যাঙ্গুয়েজের নবীনতম সংস্করণ সি১১ প্রকাশিত হয়।


উৎপত্তি

১৯৬০-এর দশকে বেশ কিছু কম্পিউটার প্রোগ্রামিং ভাষা তৈরি করা হয়েছিল। মার্কিন কম্পিউটারবিদ গ্রেস হপার Mathematic, Flowmatic এবং A2 নামে তিনটি প্রোগ্রামিং ভাষা উদ্ভাবন করেন। এরপর জেম্‌স ব্যাকাস তৈরি করেন ForTran। তারও পরে ALGOL, COBOL, Ada ইত্যাদি প্রোগ্রামিং ভাষা উদ্ভাবন করা হয়। মূলত এই ভাষাগুলিই আধুনিক প্রোগ্রামিং ভাষাগুলির পূর্বসূরী। কিন্তু ঐ ভাষাগুলিকে ভিন্ন ভিন্ন কাজে ব্যবহার করা হত। তাই কম্পিউটার বিজ্ঞানীরা এমন একটি প্রোগ্রামিং ভাষার কথা ভাবতে থাকেন যার মাধ্যমে সব ধরনের সফটওয়্যার তৈরি করা সম্ভব হবে। এরই ফলশ্রুতিতে বিজ্ঞানীরা তৈরি করেন ALGOL 60 (Algorithmic Language) এবং এরপর Combined Programming Language (CPL), কিন্তু CPL শেখা এবং ব্যবহার করা ছিল বেশ কঠিন। তাই এটা জনপ্রিয়তা পায়নি।

ক্যামব্রিজ বিশ্ববিদ্যালয় এর মার্টিন রিচার্ড CPL কে ভিত্তি করে ১৯৬৭ সালে তৈরি করেন Basic Combined Programming Language (BCPL) কিন্তু এটি ছিল মূলত Less Powerful to Specific এবং টাইপবিহীন একটি প্রোগ্রামিং ভাষা।

এ সময়েই যুক্তরাষ্ট্রের বেল গবেষণাগারে বিজ্ঞানী টমসন তৈরি করেন বি (B) নামক একটি প্রোগ্রামিং ভাষা; এটি ছিল পূর্বের BCPL-এর একটি উন্নত সংস্করণ। ডেনিস রিচি পরবর্তীতে B এবং BCPL অনুসরণ করেন এবং নিজে থেকে আরো কিছু কৌশল ব্যবহার করে তৈরি করেন "সি" (C)। মূলত B-এর সীমাবদ্ধতা গুলো দূর করার উদ্দেশ্যেই "সি" এর উৎপত্তি।

সিনট্যাক্স

কীওয়ার্ড

সি প্রোগ্রামিং ভাষায় কীওয়ার্ড বলতে বোঝায় সেইসব সংরক্ষিত শব্দসমূহকে যেগুলো একটি বিশেষ অর্থ প্রকাশ করে। সি৮৯ এ এরকম ৩২টি কীওয়ার্ড আছে।

সি৯৯ এ এরকম আরো পাঁচটি কীওয়ার্ড যুক্ত হয়।

সি১১ তে যুক্ত হয় আরো সাতটি কীওয়ার্ড।

অপারেটর

সি এর অপারেটরগুলো হল -

  • অ্যারিথমেটিক: +, -, *, /, %
  • অ্যাসাইনমেন্ট: =
  • অগমেন্টেড অ্যাসাইনমেন্ট: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
  • বিটওয়াইজ লজিক: ~, &, |, ^
  • বিটওয়াইজ শিফট্‌: <<, >>
  • বুলিয়ান লজিক: !, &&, ||
  • কন্ডিশনাল ইভালুয়েশন: ? :
  • ইকুয়ালিটি টেস্টিং: ==, !=
  • কলিং ফাংশন: ( )
  • ইনক্রিমেন্ট ও ডিক্রিমেন্ট অপারেটর: ++, --
  • মেম্বার সিলেকশন: ., ->
  • অবজেক্ট সাইজ: sizeof
  • অর্ডার রিলেশন: <, <=, >, >=
  • রেফারেন্স ও ডিরেফারেন্স: &, *, [ ]
  • সিকুয়েন্সিং: ,
  • সাবএক্সপ্রেসন গ্রুপিং: ( )
  • টাইপ কনভার্সন: (typename)

সি এর স্টান্ডার্ড লাইব্রেরি সমূহ :

The C Standard Library is a reference for C programmers to help them in their projects related to system programming. All the C functions have been explained in a user-friendly way and they can be copied and pasted in your C projects.

C Library - <assert.h>

The assert.h header file of the C Standard Library provides a macro called assert which can be used to verify assumptions made by the program and print a diagnostic message if this assumption is false.

The defined macro assert refers to another macro NDEBUG which is not a part of <assert.h>. If NDEBUG is defined as a macro name in the source file, at the point where <assert.h> is included, the assert macro is defined as follows −
#define assert(ignore)((void)0)

C Library - <ctype.h>

The ctype.h header file of the C Standard Library declares several functions that are useful for testing and mapping characters.

All the functions accepts int as a parameter, whose value must be EOF or representable as an unsigned char.

All the functions return non-zero (true) if the argument c satisfies the condition described, and zero(false) if not.

Library Functions :

Following are the functions defined in the header ctype.h −

উদাহরণ কোড

সি প্রোগ্রামিং ভাষার উদাহরন : hello world হল একটি সাধারণ প্রোগ্রামিং কোড যা সকল প্রোগ্রামার প্রোগ্রামিং কোড লিখার সময় লিখে থাকে ।

এই কোডের অংশটুকুতে "main()" নামের ফাংশন লোড হলে একটি লাইনে hello, world লেখা দেখাবে:

main()
{
    printf("hello, world\n");
}

সি প্রোগ্রামিং কোডের আদর্শ উদাহরণ

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
}
  • এখানে #include <stdio.h> লিখার মাধ্যমে কম্পেইলার কে stdio.h নামের ষ্ট্যাণ্ডার্ড ফাইল পড়তে বলা হয়েছে ।
  • int main(void) মানে মেইন ফাংশন ইন্টেজার (গাণিতিক পূর্ণ সংখ্যা) প্রদান করবে । আর (void) লিখার কারনে মেইন ফাংশনে কোন কিছু ইনপুট করতে হবে না ।
  • printf("hello, world\n") এখানে printf হল একটি ফাংশন যার বিস্তারিত stdio.h হেডার ফাইলের মধ্যে লিখা আছে । সাধারণত printf এর মাধ্যমে স্ট্রিং ডাটা কম্পিউটারের স্ক্রিনে দৃশ্যমান করার জন্য ব্যাবহার হয় । এর মানে hello world লিখাটি কম্পিউটারের স্ক্রিনে দৃশ্যমান হবে ।



ভেরিয়েবল সমূহ

ভেরিয়েবল হল প্রোগ্রামের এমন এক ধরনের ডাটা টাইপ যার মধ্যে বিভিন্ন ডাটা সংরক্ষন করা যায়। ভেরিয়েবল নিন্মোক্ত ধরনের ।

ইন্টেজার টাইপ

ক্যারেক্টার টাইপ

ডাটা টাইপ

নাম আকার (বাইট) গাণিতিক আকার নির্দেশক
Char -১২৮ থেকে ১২৭ %c
Unsigned char ০ থেকে ২৫৫ %c
Short or int -৩২,৭৬৮ থেকে ৩২,৭৬৭ %i or %d
Unsigned int ০ থেকে ৬৫৫,৩৫৫ %u
Float ৩.৪e - ৩৮ থেকে +৩.৪e + ৩৮ %f or %g
Long %ld

পয়েন্টার

এরে