Posts

If Statements in C

Image
  Decision Making/Control Statements In C Introduction Sometimes, while writing code, programmer has to take decision like, which statements or block of code to be executed and which statements or block of code to be skipped during execution. Such kind of decisions programmer can take using Decision Making Statements in C. for example if user age is above or equal to 18, user will be eligible for voting. if account balance is below minimum, user cannot withdraw money. user having multiple options and one of option has to be executed. and so on.... So, these kind of conditions decides flow of program. Decision Making Statements in C can be divided into following types 1. if statement 2. switch case statement 3. Conditional/Ternary Operator 4. goto Statement. In this Article we will see if Statements in c if Statement in C if statements are divided into following types 1. Simple if 2. if else statement 3. Nested if else statement 4. if else ladder 1. Simple if Statement : Simple...

Data Types in C

Image
 Data Types In C Introduction Type of data play very important role in Programming.  For Example: You might have filled Interactive forms on web like, Enter Your Name : Sachin Enter Your Salary : 45000.00 Enter Your Age : 30 Enter Gender : M Enter Your Phone Number : 9922970696 and so on.... In this example . . .  "Sachin" is String (Sequence of Characters/Array of Characters) 45000.00 is Real Constant, 30 is Decimal Constant, M is Single Character Constant, 9922970696 is decimal Constant. Now, to use this kind of data in programs we must have to specify Type of Data before its use. This we can do with use of Data Types in C. Data Types In C The question here is when to use Data Types. . . ? Data Types can be used while declaring Variables , Functions and so on. Variables create memory space required to store data of specific type, for example if you create integer type variable like, int num; num will get occupy with 4 Bytes of memory, now these 4 bytes can be used to st...

Variables In C

Image
Variables In C Definition  Variable in C is  "Name" given to "Memory Location", which is used to store data value of any kind. Variables can be declared  with any Data Types available  in C. for example : int, float, char and double.  int n1,n2,sum ; float pi, area ; char choice ; double Gross_Total ; Variables can also be declared using User Defined Data Types in C like structure. struct student s1 ;  here s1 is variable of type student. we can also have pointer variables, arrays etc. int *ptr ; Here ptr is pointer variable of type integer. float temp[5] ; Here temp is array name which can hold temperature of 5 cities. Compiler can process data only if at is available in memory.   Variables  create memory blocks which are used to store data values, these stored values are used during execution of program.  Example int num=10 ; here " num " is variable of type "integer" and it holds value " 10 " as data. Integer Data Occupies 2 Bytes o...