Posts

Tips and Tricks for declaring Variables

Tips and Tricks for declaring variables Declaring variables is not a easy task. It is a difficult and mind confusing task. So here, I am providing some tips that can help you to declare variables easily in C Programming. Always try to follow following points : 1. Every variable name must start with a letter(a-z , A-Z) or a underscore( _ )  2. Never start a variable name with numbers,symbols,etc 3. A variable should not contains special characters like $  < * & ^ % #, etc 4. A variable can contain only digits,letters(it may be upper case or a lower case),underscore 5. Variables must be realistic and connected to real life problem, for example if you are writing a        program for calculating total marks of student then use the variables like total_marks,etc 6. Do not use short,letter names. for example, to store student total marks don't use the variables like a,b,f,m,etc. they are confusing names.  7. Avoid ...

sizeof() Operator | Sizes ,Precision and Range of different data types

sizeof() Operator This operator is used to find out size of variables,structures ,pointers ,etc in bytes. Program to understand sizeof() opertaor #include<stdio.h> #include<conio.h> void main() { int x,y; x=98; clrscr(); y=sizeof(x); //size of variable printf("%d",y); getch(); } See Output NOTE - We will use this operator in further posts and program to understand it more. Program to find out size, precision and range of different data types #include<stdio.h> #include<limits.h> #include<float.h> void main() { clsrcr(); printf("sizeof(char)=%u\n",sizeof(char)); printf("sizeof(short)=%u\n",sizeof(short)); printf("sizeof(int)=%u\n",sizeof(int)); printf("sizeof(long)=%u\n",sizeof(long)); printf("sizeof(float)=%u\n",sizeof(float)); printf("sizeof(double)=%u\n",sizeof(double)); printf("sizeof(long double)=%u\n",s...

Programs to Understand C fundamentals

Program to understand fundamenals Escape Sequence #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("feel_the_coder\n"); // \n is the escape sequence printf("Subscibe Us\a"); // \a is also a escape sequence for a audible/visible alert printf("Give me space\t"); // \t is escape sequence and moves cursor to next horizontal tab getch(); } See Output Operators #include<stdio.h> #include<conio.h> void main() { int a,b,c; // variables a=10; b=5; c=a+b; clrscr(); if(a==10||b==6) // OR operator printf("%d",c); if(a==10&&b==5) // AND operator printf("%d",c); if(a!=b) // NOT operator printf("%d",c); getch(); } Note - if() is a conditional statement which you will study in subsequent posts. See Output Literals #include<stdio.h> #include<conio.h> void main(){ int x=5; float v=5.98; clrsc...

Environment For C | Program Development Steps

Image
Environment for C Some steps are involved in developing a c program which are as followed - 1. Program Creation 2. Program Compilation 3. Program Execution UNIX/LINUX  Environment                                                       1. Program Creation  * In UNIX C file can be created using vi editor as- $ vi filename.c * You can save this file by using ESC key and SHIFT+zz key. 2. Program Compilation * Program created in first step can be compiled using following command as- $cc filename.c * If your program contains mathematical operations the compile it as- $cc filename.c -lm * Compiled file which can be used for execution is stored in the file a.out * If you want your file to saved with specified name then compile it as follows-\ $cc filename.c -o executablename 3. Program E...

Design Methods | Process Of Software Development | Compilation

Image
Design Methods Designing is the first step for obtaining solution of a given problem.The purpose of designing is to represent solution for a system.It is difficult to design a large system because the complexity of system cannot be represented easily. Some of the design methods are given below. 1. Top-Down Design Every system has several hierarchies of components.The top level represents the whole system. Top-Down design starts from top level component to lowest components.In this design method,the system is divided into some major components. Then each major component is divided into lower level components.Similarly other components are divided until the lowest level component. 2. Bottom-Up Design Bottom-Up design method is reverse of Top-Down design approach.It starts from the lowest level components to the highest level components. It first designs the basic components and from these basic components highest level components are designed. 3. Modular Approac...

Types of Programming Language | Language Translators

Image
Programming  Languages  Before learning about c programming it is important to know about different types of programming languages and their specific features.There is always a change in scenario of popularity of programming language depending upon the need and simplicity of programmer. Programming language are classified into two types. 1. Low Level Language It is a machine understandable language.They are further divided in two categories. 1.a  Machine Level Language Computer can understands only binary digits which are 0's and 1's. So the instruction given to the computer can only be in binary code .Computer can only read binary code. So ,Every instructions must be in binary code i.e.. in the form of 0's and 1's. This Machine level language is difficult to understand this language by normal people. it is machine level language. also, this language is not in readable form. A machine level is more prone to errors and maintenance is high. Pro...

Data Types | Variables | Comments in C

Image
Data Types  Data type refers to the type of data being used for variables ,functions, etc. A datatype defines a range of allowed values and the operations that can be performed on those values. Different data types have different representation structure in  memory. Types of Data types  1. Primitive datatypes or fundamental datatype or primary datatype 2. Non-primitive datatype (These include array , enum ,structure,etc they will be discussed later) or Secondary datatype There are mainly five type of Primitive datatypes 1. int   (it is used to store integers) 2.float  (used to store floating values of single precision) 3.char    (used to store single character) 4.double  (used to store double precision floating values) 5.void (it contains nothing) Type Qualifiers  Type qualifiers are used to define properties and properties of datatypes.these are of two types. 1. Size Qualifiers They are used to ...