The Format of C

Statements are terminated with semicolons. Indentation is ignored by the compiler. C is case sensitive – all keywords and Standard. Library functions are lowercase. Strings are placed in double quotes. Newlines are handled via \n Programs are capable of flagging success or error, those forgetting to do so have one or other chosen randomly!  

Merits of C Programming

1. C is a general purpose programming language. You can generate games, business software, utilities, mathematical models, word processors, spreadsheets and other kinds of software. 2. C is a structured programming language. It uses structured statements such as while, for loops in place of goto statements which cause bugs (error) in the program. 3. System independence- … Read more

difference between an Assembler and a Compiler?

Compiler is a computer program that reads a program written in one language and translates it in to another language, while an assembler can be considered a special type of compiler which translates only Assembly language to machine code. Compilers usually produce the machine executable code directly from a high level language, But assemblers produce … Read more

A Brief History of UNIX and C

The first UNIX implementation was developed in 1969 (the same year that Linus Torvalds was born) by Ken Thompson at Bell Laboratories, a division of the tele- phone corporation, AT&T. It was written in assembler for a Digital PDP-7 mini- computer. The name UNIX was a pun on MULTICS (Multiplexed Information and Computing Service), the … Read more

a program to read the data for the customer, calculate the interest and service charge, and print the customer’s name, average balance, interest, and service charge.

//calculate interest and service charge for bank customer #include <stdio.h> int main() { char customer[30], acctNum[30]; double avgBalance, interest, service; int numTrans; printf(“Name? “); gets(customer); printf(“Account number? “); gets(acctNum); printf(“Average balance? “); scanf(“%lf”, &avgBalance); printf(“Number of transactions? “); scanf(“%d”, &numTrans); interest = avgBalance * 0.06; service = numTrans * 0.50; printf(“\nName: %s\n”, customer); printf(“Average balance: … Read more

Escape Sequences

Within the string argument to printf, the backslash (\) signals that a special effect is needed at this point. The character following the backslash specifies what to do. This combination (\ followed by another character) is referred to as an escape sequence. The following are some escape sequences you can use in a string in … Read more

Arrays of Structures & Unions in C

Since structures are data types that are especially useful for creating collection items, why not make a collection of them using an array? Similarly, we can create array of Unions. The following code snippet shows how to create an array of structures and access a particular structure element’s member. struct student { int rno; char … Read more

Union: Accessing Union Members & Nesting in C

To access union members we can use dot operator (.) between union variable and union member name as follows: <Union-Variable-Name>.<MemberAddress> For example, to access marks of union student we can do as follows: union student std2; std2.marks = 20; Now, the data member percentage of union student also contains the same value 20 but in … Read more