Posts

2 Friends in C: printf and scanf functions

Hi, The left over topics from previous post were: printf() scanf() escape sequences format specifiers In this post I will give you introduction to printf() and scanf() functions. There is a separate post for escape sequences and format specifier list. The  printf( ) function: The printf() function is used to print formatted string on the standard console. The general syntax of printf() function is as follows: 1 2 3 4 printf ( " <formatted string> " , < list of variables > ); printf( "%d" , < integer_variable > ); printf( "%f" , < float_variable > ); printf( "%c" , < char_variable > ); Line 1 shows the generic syntax of printf() function where  " <formatted string> "   should be replaced by actual string to be printed on console along with the values of variables in format specifier form.  Line 2,3 and 4 have format specifiers for integer, float and character variabl...

Quick Reference List: Format Specifier, Escape Sequence

Hi, This post will provide a quick reference list used in various places. Format Specifier List Format Specifier Description Supported Data Types %c Character char unsigned char %d Signed Integer short unsigned short int long %e or %E Scientific notation of float values float double %f Floating point float %g or %G Similar as %e or %E float double %hi Signed Integer(Short) short %hu Unsigned Integer(Short) unsigned short %i Signed Integer short unsigned short int long %l or %ld or %li Signed Integer long %lf Floating point double %Lf Floating point long double %lu Unsigned integer unsigned int unsigned long %lli, %lld Signed Integer long long %llu Unsigned Integer unsigned long long %o Octal representation of Integer. short unsigned short int unsigned int long %p Address of pointer to void void * void * %s String char * %u Unsigned Integer unsigned int unsigned long %x or %X Hexadecimal representation of Unsigned Integer short unsigned short int unsigned i...

Comments and Simple Interest Program

Comments and Simple Interest Program Hi, Theory is always boring but very important for implementation of concepts. Theory on a topic makes you aware of topic and implementation helps to explore the topic. Now, from previous post we have gone through many kinds of rules, but trust me once you start your independent programming, you will realize that what you read were not rules but just good programming practices which, when practiced helps you to develop good readable programs. We have read basic rules for constants, variables and keywords, now we will implement the same in our Simple Interest program. In between we will also learn commenting system in C. Here is program for calculating Simple Interest: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include<stdio.h> #include<conio.h> void main () { int prin, time; float rate, interest; /*Simple Interest Formula interest=(prin*rate*time)/100*/ /*Read inputs ...

Rancho Summer Vacation

Hi, The exams are over, results out and classes for next session is about to get over. Children are excited about summer vacations. Most of them busy in planning about how to spend their summer holidays. Some might be going to grandparents and others planning for a family holiday. Students of High and Higher Secondary school must be busy in studies  for their career. Some will join courses for extra curricular activities. And among them there will be a Hero, like RANCHO of 3 idiots who will do all of this and will have all the fun.  But, Rancho will have to plan very precisely. He will distribute his days for everything and will be a winner in all. Rancho will plan a holiday first. For which he will take luggage from Amazon . Rancho never wastes time and always keeps on learning one or another things, he always carries books with him which he buys from here .  After a family holiday, he is going to visit his grandparents. He cares too much for them, so he al...

Air Conditioner (AC) Buying Guide (with Recommendations)

Image
Hi, I live in Northern part of India, where yearly temperature variation ranges from 45-48degrees in Summers to 2-4degrees in Winters. In one season we are laden with sweat all the time and in other season layers of warm clothes occupy us. On one hand we seek Air Conditioners in summers on other hand we seek Heaters and Geysers in winters. In NCR, summers occupies most of the calendar, as we have 8 months of summers here. And with start of summer there starts the search for Air Conditioners. So, I was also looking for an AC, but didn't got a good guide to know in-out of it. So from whole of my research from online stores to blogs and finally visits to brick and mortar shop i felt I can help others to find an AC for their use and budget. I will pool my whole research here in this blog post. This is a must read blog post before you buy an AC. We will start with the basic of Air Conditioners, about how its works, different technologies and form factors available, then wil...

C Program: Basic Rules

Hi, In this post I will post basic C program writing rules. No need to remember these rules, as on one you will get habitual to them as you write more and more programs on other hand if you wont follow these rules, the compiler is most likely to give you error at time of compilation. The read time for this post is approx 7 mins. Rules for writing C programs: Each program in program is written as a separate statement, and complete C program consists of sequence of statements. "C" program follows the same sequence of execution as written in instructions untill and unless the control is transferred to other section of program through control statements. if...else, do...while, while, switch...case, for etc are control statements. For better readability, blankspaces are inserted between words, however, blankspaces are not allowed in naming of constants, variables or keywords. All statements should be entered in small case only. C is called free form language, as ther...

Constants and Variables

Hi, This is a long post, be patient in digesting it. Here few aspects of C which are useful from campus interview preparation as well as for MCQ's of competitive exams. The section contains Rules for naming constants and variables along with some Test Yourself questions for checking your conceptual understanding. The read time for this post is about 10mins. After understanding this post you will be able to answer:  Inventors of C.  Why C?  Arguments for learning C from programmer’s point.  Constants and Variables in C along with rules to define them.  Acceptance of C: C was found in 1972, by Dennis Ritche . After initial hesitation, C was widely accepted and appreciated programming language due to simplicity and ease of use. There is no harm in calling C as the universal programming language as whatever can be done on any other language is quite possible to do in C. It has been almost 5 decades of domination by C, where many ...