Skip to main content

Posts

Showing posts from March, 2018

Data Input/Output

DATA INPUT / OuTPUT When we make a program, we need to get some data from user and display some data to user. Since data is of various types like a Real Number, Integer Number, Characters or String. Thus there are various syntax to get various data from user and to display data. Here are the One Line Syntax to input and display data: 1-      Integer : Input: scanf(“%d”,&a); Output: printf(“%d”,a); 2-      Float : Input: scanf(“%f”,&b); Output: printf(“%f”,b); 3-      Character: Input: scanf(“%c”,&c); Output: printf(“%c”,c); 4-      String: Input: scanf(“%s”,st); OR gets(st) Output: printf(“%s”,st); OR puts(st) 5-      Long Double Input: scanf(“%ld”,&xx); Output: printf(“%ld”,xx); 6-      Long Float: Input: scanf(“%lf”,&yy); Output: printf(“%lf”,yy); Here is an example of a program fo...

Variable: Declaration, initialization and Usage

Variable Variables are the names given to some memory location where a value is stored; the variable is corresponding to the data or value input in it. RULES FOR DEFINING A VARIABLE / VARIABLE NAME: · A Variable name should not have name of any KEYWORDS in C. · A Variable name can be alphanumeric but should start with an Alphabet. · A Variable name should not consist of any special symbol other than “_” Underscore Symbol.  · A Variable should be defined before using it. VARIABLE DECLARATION: In this step, the variables are declared, this steps always occurs before using the variables. FORMAT:   EXAMPLE: VARIABLE INITIALIZATION: Providing a Value to any variable is called initialization. INITIALIZATION AT THE TIME OF DECLARATION: The variable can be given its value at the time of declaration. USAGE OF VARIABLE: Here is the example, to show how a vari...

Data Types In C: Size, Range and Usage.

DATA TYPES IN ‘c’ Data types are keywords which specify the type of data which is used in the programs of C language. Different data types have different storage capacities and different range of data. There are mainly two main categories of data types. PRE-DEFINED DATA TYPES/PRIMARY DATA TYPES INTEGER TYPE DATA TYPES Integer type data type is used to store a whole number or integer number Type Size(bytes) Range int or signed int 2 -32,768 to 32767 unsigned int 2 0 to 65535 short int or signed short int 1 -128 to 127 unsigned short int 1 0 to 255 long int or signed long int 4 -2,147,483,648 to 2,147,483,647 unsigned long int 4 0 to 4,294,967,295 FLOAT TYPE DATA TYPE Float type data types are used to store a real number. Type Size(bytes) Range Float 4 3.4E-38 to 3.4E+38 double 8 1.7E-308 to 1.7E+308 long double 10 3.4E-4932 to 1.1E+4932 CHARACTER DATA TYPE Character type data type is used to store Character type value ...

Keywords and Comments in C

KEYWORDS IN C For better blogs do comment your opinion and share the blog What are Keywords? Keywords are the words that convey a special meaning to the compiler. This means the meaning of every particular keyword is already defined to the compiler of the Language. There are total 32 Keywords in C Language and all have their meaning fixed to the compiler. These are the keywords in C. auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while The Keywords in Red are the data types they are used to define the data type of a variable. Example: int i; float f; char ch; long l; The Usage of these keywords will be covered as they arrive ...

Basic Structure of 'C' Program and Printing Hello,World! in 'C'

The Basic Structure of ‘c’ Like most of the programming languages, C too has a structural approach and hence it has a basic structure. Here is the basic structure of a typical C program: 1)     DOCUMENTATION A Typical Program consist s of Documentation, in which the Details regarding the program and the programmer are written in comments. 2)    HEADER FILES: LINK TO THE C LIBRARY Header Files links the Various Library modules, classes to the program, Header files Includes methods from C Library with a “ #include ” command and the function name within < > symbols. E.g.: include<stdio.h> which includes Standard Input Output Methods to C Program. 3)    DEFINITION define directive is used to define a variable whose value stays same throughout the program. E.g.:   #define PI 3.14 4)   GLOBAL DECLARATIONS The Functions other than main () are declared here in global declaration section E.g.: ...

Features of 'C'

Features of ‘C’ Although ‘C’ is one of the elder language to be known, it have some Features that were exclusively present in the Language, ‘C’ became the first Language to possess some of the following Features. Ø SIMPLE :  ‘C’ is a simple language with a structural approach , which means it have ability to divide problems into meaningful parts. Functions (), Data types and rich library makes it simple. Ø PORTABLE (MACHINE INDEPENDENT) : ‘C’ is a machine independent language, which means it have WORA ( Write Once Run Anywhere ) property, thus a program written on one OS or device can run on any other OS or device, with none or negligible modifications. Although ‘C’ was developed to work on UNIX Platform, but later on it became Portable.     Ø RICH LIBRARY: ‘ C’ provides a rich library with lot of pre-defined functions which make development of a program easy. Ø MEMORY MANAGEMENT: ‘C’ have better memory management since it provides Dynamic ...

History of the 'C' Programming Language

The History of ‘C’. The ‘C’ Language was developed by Dennis Ritchie at AT&T Bell Laboratories, USA in year 1972. The ‘C’ language was originally designed for and implemented on the UNIX Operating System. All Essential UNIX applications are written in C.   The Language was known to be BCPL and B’s killer, since It almost overtook their legacy and started its own. Since ‘B’ and ‘BCPL’ were type-less languages, C became first language to provide variety of data-types . In 1978 “ The C Programming Language ”, book written by Kernighan & Dennis caused Revolution in the world of Computer Science. In 1983, ANSI (American National Standards Institute), established a committee for providing a comprehensive and modern definition of C.  Thus ‘ANSI C’ was completely developed in 1989. Thus ANSI C is also known as C89.  (ISO) International Organization of Standardization had also contributed to standardize C. PREDECESSORS AND SUCCESSO...