Programming in C in 7 days
#1

[attachment=8761]
Programming in C in 7 days
1-1 Introduction

This course is a quick tutorial on C Programming language. We assume that you are familiar with
at least one of famous operating systems.
For this course you can use the following compilers or Programming Environments.
cc in Unix or gcc in Linux operating systems
Borland C or Turbo C in DOS operating system
Visual C++ (create a simple win32 console application.) in Windows
C++Builder (create a console application using console app wizard) in windows
We suggest a simple environment like Unix, Linux or DOS. Windows compilers are very complex
for newbie programmers.
1-2 Your first C program
Let's write our first C program.
#include <stdio.h>
main()
{
printf("Hello World!\n");
}
First step for running this program is to make a text file containing above code. Be sure that the
file is a pure text file. You must save the text file with .c extension.
Then you must compile the source code. The result of compile step is an executable file that you
can run it.
To compile program under most of Unix operating systems you will use the command:
$ cc test.c
and under linux:
$ gcc test.c
The resulting executable file is a.out file. To run this executable you must type:
$./a.out
Program output must appear on your screen.
Hello World!
To compile the source code in other environments, you must use their Development Environment.
You must consult your compiler User's Guide for this.
If you have problem working with your compiler you may ask your problem in our support forums.
1-3 Details of Test program
#include <stdio.h>
Tells C compiler to include the file "stdio.h" in this point of your C program before starting compile
step. This "include file" contains several definitions , declarations etc.
main()
C program consist of one or more functions. Functions are building blocks of C programs. main()
function is different from other functions by that it is the start point of program execution. Our
program contains only function while complicated programs may contain thousands.

{

Opening brace marks the start of a block. Closing brace will mark its end. This one marks main ()
function start
printf("Hello world!");
This line of code prints the statement between quotation marks on your output screen. \n tells
program to start a new line in output screen.
Each command line in C ends with ";" character. Control statements are exceptions. You will soon
be able to
determine when you must use ; to end a line of code.

}
closes main() function. This program contains only one function while complicated programs may
contain several functions.
1-4 Data types and variables
C uses several data types of data. These include characters, integer numbers and float numbers.
In C language you must declare a variable before you can use it.
Declaring a variable to be an integer or a character for example will let computer to allocate
memory space for
storing and interpreting data properly.
1-5 Naming a variable
It's better that you use meaningful names for your variables even if this causes them to became long names. Also take this in mind that C is case sensitive. A variable named "COUNTER" is different from a variable named "counter".
Functions and commands are all case sensitive in C Programming language. You can use letters,
digits and underscore _ character to make your variable names. Variable names can be up to 31 characters in ANSI C language.
The declaration of variables must take place just after the opening brace of a block. For example we can declare variables for main() function as below code:
main()
{
int count;
float sum,area;
.
.
.
}
First character in a variable name must be a letter or an underscore character. It cannot be a C
programming
language-reserved word (i.e. Commands and pre defined function names etc)
An example for using variables comes below:
#include<stdio.h>
main()
{
int sum;
sum=12;
sum=sum+5;
printf("Sum is %d",sum);
}
General form for declaring a variable is:
Type name;
The line sum=sum+5; means: Increase value of sum by 5. We can also write this as sum+=5; in
C programming language.
printf function will print the following:
Sum is 17
In fact %d is the placeholder for integer variable value that it's name comes after double quotes.
Common data types are:
int : integer
long : long integer
float : float number
double : long float
char : character
Other placeholders are:
%d : decimal integer
%ld : decimal long integer
%s : string or character array
%f : float number
%e : double ( long float)
printf () function used in this example contains two sections. First section is a string enclosed in
double quotes. It is called a format string. It determines output format for printf function. Second
section is "variable list" section.
We include placeholders for each variable listed in variable list to determine it's output place in
final output text of printf function.
1-6 Control characters
As you saw in previous examples \n control character makes a new line in output. Other control
characters are:
\n
\t
\r
\f
\v
New line
tab
carriage return
form feed
vertical tab
1-7 Multiple functions
Look at this example:
#include<stdio.h>
main()
{
printf("I am going inside test function now\n");
test();
printf("\nNow I am back from test function\n");
}

test()
{
int a,b;
b=a+100;
printf("a is %d and b is %d",a,b);
}
In this example we have written an additional function. We have called this function from inside
main function. When we call the function, program continues inside test () function and after it
reached end of it, control returns just after test () function call in main ()
You see declaring a function and calling it, is an easy task.
Just pay attention that we used ";" when we called the function but not when we were declaring it.
We finish this lesson here. Now try to do lesson exercises and know the point that you will not
learn anything if you do not do programming exercises.
Reply
#2

[attachment=9142]
C – Programming
History of programming languages

In the 1950s, the first three modern programming languages whose descendants are still in widespread use today were designed:
FORTRAN (1955), the "FORmula TRANslator", invented by John Backus
LISP, the "LISt Processor", invented by John McCarthy
COBOL, the COmmon Business Oriented Language, created by the Short Range Committee, heavily influenced by Grace Hopper.
Another milestone in the late 1950s was the publication, by a committee of American and European computer scientists, of "a new language for algorithms"; the ALGOL 60 Report (the "ALGOrithmic Language"). This report consolidated many ideas circulating at the time and featured two key language innovations:
Nested block structure : code sequences and associated declarations could be grouped into blocks without having to be turned into separate, explicitly named procedures;
Lexical scoping : a block could have its own private variables, procedures and functions, invisible to code outside that block, i.e. information hiding.
Some important languages that were developed after this period include:
1968 - Logo
1970 - Pascal
1970 - Forth
1972 - C
1972 - Smalltalk
1972 - Prolog
1973 - ML
1975 - Scheme
1978 - SQL
C-Language Introduction
C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system
Although C was designed for implementing system software it is also widely used for developing portable application software.
C is one of the most popular programming languages and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++ which began as an extension to C.
C has been already superceded by other languages like C++, C#,VB, java,etc. so why bother to learn C today? There are several reasons like this,
(a) Nobody can learn C++ or Java without understanding things like classes, objects, inheritance, polymorphism,templates,exception handling, etc.
(b) Many languages like C++ and Java can make use of a principal called object oriented programming tools and frameworks but using these frameworks and tools you would be still required to use the core C language elements.
© Major parts of popular operating systems like Windows, UNIX, Linux as still written in C. so even today when it comes to performance nothing beats C.
(d) Mobile devices like cellular phones, palmtops with consumer devices like washing machines, microwave, digital cameras are having microprocessors, an operating system and a program embedded in these devices.
Steps in learning C
C constants, variables and keywords :
The alphabets, numbers and symbols when properly combined form constants, variables and keywords.
Constant is a entity that never change and the variable is a entity that may change.
C Constant
Integer constant

(a) An Integer constant must have atleast 1 digit.
(b) It must not have a decimal point.
© It can be either positive or negative.
(d) If no sigh proceeds an integer constant, it is assumed to be positive.
(e) No commas or blanks are allowed.
(f) The allowable range for integer constant is -32768 to 32768.
It can also state that the range of an integer constant depends upon the compiler. The above range is for 16 bit. For 32 bit compiler the range would be even greater.
Real constant
(a) A real constant should have atleast 1 digit.
(b) It must have a decimal point.
© It could be either positive or negative.
(d) Default sign is positive.
(e) No commas or blanks are allowed within a real constant.
The exponential form of representation of a real constant is either too small or too large.
Character constant
(a) A character constant is a single alphabet, a single digit or a single special symbol enclosed within a single inverted comma. Both the inverted commas should point to the left.
(b) The maximum length of a character constant can be 1 character.
Character constant have integer values that are determined by the computers particular character set. Thus the value of a character constant may vary from one computer to another. The constant themselves, however, are independent of the character set. This feature eliminates the dependence of a C Program on any particular character set.
Most computers and virtually all personal computers make use of ASCII character set, in which each individual character is numerically encoded with its own unique7-bit combination.
C Keywords :
Keywords are the words whose meanings has already been explained to the c compilers. The keywords can not be used as variable names because if we do so, we are trying to assign a new meaning to the keyword, which is not allowed by the computer. Some c compilers allow to construct variable names that exactly resemble the keyword. There are only 32 keywords available in C. some compilers may recognize other keywords. The all keywords are all lowercase. Since uppercase and lowercase characters are not equivalent , it is possible to utilize an uppercase keyword as an identifier. Normally, however, this is not done, as it is considered a poor programming practice.
First C program
By knowing all the concepts about the variable, keywords and constants the next logical step is to combine them to form the instructions.
Before starting to proceed with the program we all must remember the rules applicable to the all C programs.
(a) Each instruction in the C program is written as a separate statement. Therefore, a complete C program would comprise a series of statements.
(b) The statement of a program must appear in the same order in which we wish them to be executed, unless of course the logic of problem demands a deliberate ‘jump’or transfer of control to a statement, which is out of sequence.
© Blank spaces may be inserted between two words to improve the readability of the statement. However, no blank spaces are allowed within a variable, constant or keyword.
(d) All statements are entered in small case letters.
(e) C has no specific rules for the position at which a statement is to be written. That’s why it is often called free from language.
Every C statement must end with semicolon (Wink. Thus (Wink acts as a statement terminator
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: ppt for morden days technology, the estimated time for the critical path is 120 days, who is kristen on days, f1 track days, 797 next kerala lottery 2 days result number, recognition days 2011, number school days academic year,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Dynamic programming language seminar projects crazy 2 3,178 03-01-2013, 12:31 PM
Last Post: seminar details
  SEMINAR ON MICROENGINE PROGRAMMING IN NWP computer girl 0 992 09-06-2012, 03:09 PM
Last Post: computer girl
  UAV DevBoard: Getting Started with PIC Programming computer girl 0 1,011 09-06-2012, 11:35 AM
Last Post: computer girl
Music D Programming Language Computer Science Clay 2 2,563 14-03-2012, 02:35 PM
Last Post: seminar paper
Thumbs Down Extreme Programming (XP) computer science crazy 2 2,071 14-03-2012, 11:57 AM
Last Post: seminar paper
Photo Genetic Programming (Download Full Report And Abstract) computer science crazy 3 3,847 29-02-2012, 09:35 AM
Last Post: seminar paper
  GENETIC PROGRAMMING A SEMINAR REPORT Computer Science Clay 3 4,336 29-02-2012, 09:35 AM
Last Post: seminar paper
  Introduction to the C Programming Language seminar class 1 6,575 14-02-2012, 01:43 PM
Last Post: seminar paper
Brick Categorization of Programming Languages computer science crazy 1 1,861 14-02-2012, 01:43 PM
Last Post: seminar paper
  D (programming language) seminar surveyer 2 2,656 14-02-2012, 01:43 PM
Last Post: seminar paper

Forum Jump: