Chap. 1 : Unit 3 : Introduction to Language: Part 2

Friends…. many students ask me why to learn C language in the era of .NET, Java, PHP, so my answer is when you learn C, you learn language fundamentals which are common to all languages in last 20 years. Same is explained here in this video.

Friends…. I discussed on operating system more than you might have hardly expected only because, we will be writing our C programs under DOS platform as well as recently developed IDE. Now just see the word platform…and how generically it is used….

As we already know, to run any application we need an operating system…. For cooking you need kitchen platform…or for swimming you need swimming platform…I mean without water can anybody swim…?

Now swimming platform may be different… like swimming pool, river, and lake or say ocean….but we need that….

To play games like cricket, football, hockey or tennis we need ground….

In the same fashion we need a platform in the computing world and here operating system performs that function…. And many times it is called as platform… Great know?

We might have heard about a few frameworks launched by Microsoft…. Like a .net framework…. A much hyped word these days among you programmers…. Just like talk of the town…. It is also manytimes called as a platform….!

Had you been to a gift article shop recently…? If yes you might have seen a frame… a photo frame…your job is to insert a photo of your choice in it…that’s all…. Sounds good know….just like plug and play…. No more hassles….

But my dear girls and guys ….we should not start our journey of learning merely by inserting only photos but instead learning how to build that frame itself…. So that we learn the foundation….and my dear friends…C provides that knowledge to understand the basics of all latest technologies like VC++, C sharp, J sharp, ASP dot net, PHP, python ….etc…

That is the reason we are going to learn C programming as a first language before learning any other technology….

And at the same time we are going to write our programs under the DOS environment as well as one IDE called C Free…. But does not matter whether it’s UNIX or Linux or DOS or window based platform

Because syntaxes and philosophy is same everywhere…. It’s like vanilla is base for any flavor of Ice-cream…. Other varieties would be added flavors like strawberry, Mango, chocolate.

Similarly learning C is important and flavors might be C under the DOS platform, C under Windows, C under UNIX, or even C under Linux ….

Syntaxes will be same with minor changes… in Nokia phones symbian C was also a new platform for writing mobile applications… and many components of android have been written in C and C++…

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. Register for Discount Coupon


Chap. 1 : Unit 6 : Sample C Program : Part 5

Here we will write one more program of calculating area of a circle. The idea of this program is to understand defining proper data types of variables in a C program. 

Here we need at least 2 variables. One for storing radius of a circle and other one for storing area of the circle. The data type of radius may be an integer or float but as formula of circle contains constant of PI which is 3.14, a floating point constant, the area variable must be declared as float or double to store the value. 

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register free (log in ) on Register / Login


Sample C Program Part 4

Chap. 1 : Unit 6 : Sample C Program : Part 4

In this video we will try to explore escape sequence, the facility provided by Dennis Ritchie to get the well formatted output on the screen and also how format specifiers can be used in printf and scanf functions.

Writing slash n escape sequence at the end of printf statement string is good programming practice. 

Now we will have a closer look at a very close friend of printf function….i.e. scanf function…. Scanning basically involves retrieving something who wishes to give…. Here we want program to scan data from the keyboard which is entered by the user…. So is the scan function….i.e. scanf…. It is part of stdio.h header file like that of printf. 

The second guest which appears both in printf and scanf function is %d. it is called as format specifier for integer constant. When encountered in printf function, value in the variable is printed in the integer format where percent d appears.

On the contrary, when %d is encountered in scanf function, program waits for user input and expects integer input from the keyboard. When integer constant is entered then that number scanned is stored at the address contained in corresponding variable in the variable list written after first comma. That is why & is attached as unary operator ahead of variable name and is called address operator. 

In the above example when first scanf function is executed, input from the keyboard say 10 will be stored at the address of x where as when second scanf function is executed, input from the keyboard say 20 will be stored at the address of y….

In the output printf statement we have written sum is equal to percent d, so it will print contents of the variable sum in place of %d…. in integer format, i.e. it will give output as Sum is equal to 30.

If we want output as 10 + 20 = 30 then we need to write format specifier at each location and access contents maintaining same sequence as that of sequence of format specifier…. So here if you write printf %d plus %d equal to %d then comma separated sequence should be x, y, and sum.

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register free on (log in Tab) Register / Login


Chap. 1 : Unit 6 : Sample C Program : Part 3

This video explains how to save the file in proper folder and how to compile the program in DOS environment. 

Now save the file. This code is called as source code. While saving the program make sure that it is saved in the appropriate folder of your own. Now it is the time to compile the source code to convert it into machine code. Under the DOS environment menu has provide the compile option…when you compile pop up window will give you information like name of file getting compiled, number of lines being compiled, number of warnings and number of errors etc. in the Linux environment gcc is the command which has to be given at the command prompt followed by file name followed by executable file name.

Dear friends, it is common misconception that compiler is meant for finding errors. But its primary task is to convert the source code into machine level language or object code. During this process if it encounters any hurdle due to syntax irregularities then it throws errors and warning. Also errors and warning are given as a hint for programmer to rectify and correct. So line number for error and warning should not be taken literally.

Suppose you have declared a variable but not used in the program, it may give warning message or if you forget to write return type of main function it may give you warning or error message. For example under the DOS environment if you forget to write void before main it will give you warning message as function should return a value…

But don’t forget that warning is never for ignoring purpose. In C also you should never ignore warning no matter how trivial those are…

Compile time errors may be due to many reasons like you have used variable without declaration, or you forget to write closing curly brace of main function or forget to put semicolon to terminate the statement and so on….which may create trouble for you…

But never ever, I mean never ever lose the patience, no matter how many errors or warnings are encountered during program development. Because errors and warning will teach you the programming and indicates that you are learning programming on the right track. After all to err is the human… know?

Once all errors and warnings are identified and rectified, you are ready for executing the program…however one can encounter errors while execution of the program which generally is called as run time errors. These are generally occurred due to either logical errors in the program or due to memory leak due to pointers. We will study these as and when we come across such topics.

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register free (log in ) on Register / Login


Chap. 1 : Unit 6 : Sample C Program : Part 2

This video explains you file inclusion at the beginning of program and also how to start writing simple C code to print message, how to take input and how to print the result of summation of two integers. 

Earlier we have tried to study many statements individually… but now we will try to write a program using these statements…

Usually a few library files like stdio.h, conio.h, stdlib.h needs to be included at the beginning of C program. Its use and purpose will be discussed later in the syllabus. So write a statement #include stdio.h and #include conio.h.

So write on the first line # include stdio.h…. and on the next line #include conio.h

Now start program by writing function by writing int or void followed by main followed by pair of round brackets…as pair indication of function as said earlier. As main is one of the important function in C, brackets need to be written in front of this

So whatever we are going to write in C program will be from here onwards…

Here we are going to try to get addition of 2 numbers using C program….So Here we will declare 3 variables namely x, y, and sum all having integer data type, by writing int x, y, sum…

Now we will call one library function called clrscr to clear the screen. Under DOS environment you may require to call but for other environments you will have to check compiler manuals… the earlier contents available in the buffer of monitor may get displayed during next execution so clear screen function will clear it from the screen…this is a function available in the conio.h library so this file is included

If we want to print Welcome to C Programming on the screen then you can write printf 

This function is called from the library and is part of stdio.h file so this file is usually included before main. as printf function is available in this library file…

To take the input from the keyboard one more library function is available in the library which is called as scanf…it stands for scan function and On the next line we can write printf 

You can terminate here the main function by writing getch function followed by closing curly brace on the next line…

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register free (log in) on Register / Login


Chap. 1 : Unit 6 : Sample C Program : Part 1

Till now we have seen syntaxes of various parts of general C Program like type declaration, operators and operands, keywords, constants etc. Now it is time to use all this concepts and write a simple program. 

First C language Program

Before we write our first C program we need to know menu of the turbo C compiler. 

usually icon is created or even you can create shortcut of turbo C compiler on the desktop. When compiler is opened you will get a blue screen with menu at the top. Turbo C compiler is most popular among programmers and so we are going to use the same. However as told earlier you can use any compiler as per your convenience. 

Select new from the file menu and you will get default workspace to write a C program. Either at the top of screen at the middle or at the right end corner at the top you will see default name of the file as noname.c. Also you can see line number and column number. 

Every program must be saved by the programmer before he or she starts writing the program. The file name should be small and meaningful. While saving the file, it should be saved in a proper directory created by the user. We will study all components of Menu in next few chapters when we need them. 

The C program is written inside the main function, however detailed study of function will be discussed later in the syllabus. 

Now following points need to be undestood and remembered as well. enlightened

  • We have to write main function in each C program,
  • Any C program can contain one and only one main function
  • Execution of any C program starts always from the main function
  • You need to write return type of main function before the main word
  • The whole C program is written in lower case alphabets
  • Each C statement is terminated by semi colon
  • However capital letters inside the print function are allowed as they become part of the string,
  • C program is a collection of functions 

Now we will write all those statements which we studied earlier in a proper way 

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register (log in) free on Register / Login



Chap. 1 : Unit 5 : Structure of C Language : Part 5

C language मध्ये program लिहीताना user कडुन input घेणे, प्रक्रिया करणे, output monitor वर print करणे ही कामे करावी लागतात. output print करताना C मध्ये उपलब्ध असलेले library functions वापरणे जरुरी असते. library मध्ये printf() enlightened हे फंक्शन आहे. त्याचा वापर केल्यास आपल्याला screen वर print करता येते.

समजा तुम्हाला welcome to C programming हे screen वर print करायचे असल्यास तुम्ही printf(“welcome to C programming”); असे program मध्ये लिहावे लागेल. ते print करण्यासाठी चे function असल्या मुळे त्याला printf function असे संबोधतात.

memory मध्ये असलेली value जरी तुम्हाला print करायची असली तरी तुम्ही याच function चा वापर करु शकता. समजा x आणि y अशी दोन variables तुम्ही dclare केली आहेत. त्यामध्ये दोन integer store करुन त्याची बेरीज करुन तुम्हाला ती sum या integer variable मध्ये store करायची आहे. ते तुम्ही sum = x + y असे expression लिहुन करु शकता.

पण ते print करायचे असेल तर तुम्हाला ते statement printf(“sum = %d”,sum); असे लिहावे लागेल. printf(“welcome to C programming”); व printf(“sum = %d”,sum); या statements चा आपण सविस्तर अर्थ आता पाहु कारण आपण अशी अनेक प्रकारची library functions सर्व C च्या topic मध्ये वापरणार आहोत. 

या मध्ये printf() हे function आहे कारण round brackets आहेत. त्याच्या आत एक , आहे याचा अर्थ दोन parameters आहेत. पहीले हे शक्यतॊ “ मध्ये असते त्याला string असे म्हणतात. ही string जशी आहे तशी screen वर print केली जाते. वर असलेल्या पहिल्या printf function मध्ये string मध्ये welcome to C programming असे लिहीले आहे. म्हणुन ते तसेच print होते.

दुसऱ्या printf function मध्ये string मध्ये sum = %d असे लिहीले आहे. त्या मधील sum =  हे आहे तसे print केले जाते. त्या नंतर %d लिहीले आहे. याला format specifier enlightenedअसे म्हणतात. आपल्याला x या variable मधील value integer स्वरुपात print करायची आहे. ते संगणकाला व compiler ला कळण्यासाठी format specifier लिहावा लागतॊ. %d हा integer साठी format specifier आहे. तो string मध्ये ज्या ठिकाणी तुम्ही लिहाल त्या ठिकाणी तो पहील्या ,च्या नंतर variable असेल त्यामधील value print करण्याचे काम करतॊ. वर दुसऱ्या printf statement मध्ये , नंतर sum मध्ये sum मधील x + y ची बेरीज जी store करुन ठेवली आहे ती print करेल. 

समजा x मध्ये 5 व y मध्ये 10 store केला असेल तर १५ ही sum या variable मध्ये store केली जाईल. समजा आपल्याला output 5 + 10 = 15 असे हवे असेल तर printf स्टेटमेंट printf(“%d + %d = %d”,x,y,sum); असे लिहावे लागेल. या मध्ये पहील्या %d च्या वेळी तॊ x मधील, दुसऱ्या %d च्या वेळी y मधील व तिसऱ्या %d मध्ये sum मधील value print करेल.

त्यामुळे format specifier चा sequence व variable चा sequence हा सुसंगत असण्याची काळजी programmer ने घेतली पाहीजे.smiley 

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc.


Chap. 1 : Unit 5 : Structure of C Language : Part 4

गेल्या १०-१२ वर्षाच्या शैक्षणिक कारकीर्दीमध्ये जितके ऑपरेटर पाहीले नसतील किंवा ऐकले नसतील त्यापेक्षा जास्त ऑपरेटरचे नमूने (माणसांप्रमाणेच) तुम्हाला या C programming language बघायला मिळतील/भेटतील/सापडतील किंवा आडवे येतीलlaugh. त्यांना वेगवेगळे अर्थ द्यायच डेनीस रिची च कौशल्य सुद्धा दिसेल… “मोठ्ठा माणूस” angel

We will study Ternary operator in the next chapter. Besides… in C, other than unary minus, ++, –, & are some of the examples of unary operators…. In mathematics, one can write expression like 3x + 4y equal to z…. but in C, its invalid statement. As per the rules stated by Dennis Ritchie, there should be variable on the left hand side and more importantly nothing is implicit while writing expression i.e. in mathematics 3x means 3 into x  but in C it gives an error and should be written as 3 into x! So above expression must be written as 3 into x plus 4 into y assigned to z in C I would like to reiterate one more important rule that, in C…. value of the expression on the right hand side or constant on the right hand side is assigned to variable on the left hand side. So though x is equal to x plus 3 is invalid statement in mathematics, it is valid in C. the reason is that here, 3 is first added to current value in the variable x and then the new value of expression is stored in… x itself. So if x contains 5 and expression is written as x is equal to x + 1 then 1 will be added to 5 and the new value i.e. 6 will be stored in x…. Hierarchy of Operators While solving an algebraic expression in school, you might have studied operator precedence rule. For example while solving the expression x is equal to 4 plus 5 into 7 divided by 9 minus 3 into bracket, you first solve the expression inside bracket then multiplication and division and addition in the last and then store the result in x…isn’t it? In C this is called as operator hierarchy. The chart of operator hierarchy is given here as in the standard book. Further we will solve a few small programs as well in the end of the chapter. Besides hierarchy, associativity also comes into picture when adjacent operators are having same precedence. For example in the above example multiplication and division operator have got same precedence. In such situation, expression needs to be solved from left to right. For few operators category like that of assignment operators, associativity is from right to left.

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register for Discount Coupon


Chap. 1 : Unit 5 : Structure of C Language : Part 3

गणित म्हणजे शाळेपासून भुताप्रमाण पाठ न सोडणार सब्जेक्टindecision…आणी Mathematics मला कधीच अवघड गेल नाही अशी समजूत असेल तर M2 चा पेपर दिलेल्यांना विचारा crying मी म्हणतो ते खरयं की नाही ते…तर मग प्रोग्रॅमिंग लॅंग्वेज कशी त्याला अपवाद असेल? पण या ठिकाणी डेनीस गुरूजीनी गरजे नुसार त्यांच्या नियमा मध्ये थोडाफार फरक केला आहे. समजून घ्यायचा महत्वाचा पार्ट म्हणजे तोच… !enlightened

Arithmetic Instructions

It simply means mathematical equations or formulas. In arithmetic instruction in C, variable is always on the left hand side of assignment operator and constant or expression is on the right hand side of assignment operator. For example int x, sum. float average, pi, x = 5, pi = 3.14, sum = m1 + m2 + m3, average = total /5 are example of arithmetic instructions.

Very important point here is equal to operator in C is actually called as assignment operator. So instead of reading the statement x = 5, it should be read as “5 is assigned to x”….!

Last 4 statements are example of arithmetic instructions. If you closely observe all of these statements, you will find that constant or value of the expression on the right hand side is assigned to variable on the left hand side of assignment operator…

In the above example, 5 and 3.14 are integer and floating point constants where as m1, m2, m3, average, sum, pi, and x are name of variables. Collectively these are called operands when used in expressions whereas assignment, plus, and division are called as operators. So operators operate upon operands.

C language is very rich in operators say almost 50 and Dennis has cleverly used all these special characters as operators. All these operators have been divided into three broad categories viz. unary operators, binary operators and ternary operators.

Unary operator has got one operand, binary has got two operands and that of ternary obviously has got three operands

These all operators have been further categorized into sub categorized like arithmetic operators, relational operators, assignment operators, logical operators and so on but at one go we will not discuss all of these. Right now we will limit our discussion to only arithmetic operators  namely addition operator, subtraction operator, multiplication operator, division operator and modulus operator  all of which are binary operators except minus which is unary as well as binary in C language.

For example let’s consider two statements 5 plus 4 minus 1 assigned to x and sum divided by 5 assigned to average

Here 5, 4, 1, x, average, sum and 5 are called as operands and plus, minus, and division are called as arithmetic operators. In C percentile sign gives remainder of division of two numbers so for example 25 mod 3 assigned to x statement when gets executed store 1 in x as remainder. But 25 / by 3 assigned to x will give the output as 8.

The reason is in C if both operands are integer then result of their operation is integer where as result would be float if either or both of operands are float for example if x is a float variable then 25 / 3.0 gives output as 8.33. if you can recall mathematics in school, product of -4 and 5 is -20 because one of them is negative

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register for Discount Coupon


Chap. 1 : Unit 5 : Structure of C Language : Part 2

मॉल मध्ये जातो, मार्केट मध्ये जातो, आपण माणसं काही ना काही खरेदी करून आणतो…विचारही करत नाही त्या वस्तूचा आपल्याला उपयोग आहे की नाही…प्रोग्रॅमिंग मध्ये मात्र असं चालत नाही.enlightened जशी गरज तशीच व्हेअरेबल्स डिक्लेअर करायला लागतात नाहीतर ढिगभर error आणी warnings नक्कीच मिळणार…!smiley

Type declaration Statements

In any C program, we need to declare variables at the beginning of a program i.e. at the beginning of a function. This declaration is called as type declaration statements. As the rule suggests, all variables need to be declared before its use.

As said earlier it instructs the compiler to allocate memory on the basis of data type. Int basic_salary, float percentage, char grade are a few examples of type declaration statements and generally 2, 4 and 1 bytes of memory is reserved respectively for these variables. Obviously I am talking about memory reserved under the DOS environment. If you are using any other compiler then you will have to check number of bytes reserved for various data types.

We declare data type of variables depending upon type of constant we intend to store or presume to be stored… after calculation.

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register for Discount Coupon