Programming in C in 7 days
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
seminar class
Active In SP
**

Posts: 5,361
Joined: Feb 2011
#1
18-02-2011, 10:21 AM



.docx   Programming In C In 7 days.docx (Size: 282.21 KB / Downloads: 83)
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
seminar class
Active In SP
**

Posts: 5,361
Joined: Feb 2011
#2
26-02-2011, 09:52 AM


.ppt   C language- Minakshi Gadekar.ppt (Size: 162.5 KB / Downloads: 60)
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
seminar flower
Super Moderator
******

Posts: 10,120
Joined: Apr 2012
#3
25-06-2012, 01:32 PM

Programming in C in 7 days


.pdf   Programming in C in 7 days.pdf (Size: 736.71 KB / Downloads: 49)
Quick Start with C

programming language is perhaps the most popular programming language. C was created in 1972 by
Dennis Ritchie at the Bell Labs in USA as a part of UNIX operating system. C was also used to
develop some parts of this operating system. From that time C programming language has been the
de facto programming language when fast programs are needed or the software needs to interact
with the hardware in some way. Most of the operating systems like Linux, Windows™, and Mac™ are either
developed in C language or use this language for most parts of the operating system and the tools coming
with it.
This course is a quick course on C Programming language. In our first lesson we will first write our first
C program. We will then learn about printing to screen, variables and functions. We assume that you are
familiar with at least one of the popular operating systems.

Compiling and Running under Windows with Dev-CPP

To develop, compile and run the program in Bloodshed environment follow below steps. If you have
problem working with your compiler you may ask your problem in our support forums.
1- Run bloodshed and select “New -> Project” from File menu. In the appeared window enter a name
for your project and implimentation (Figure 1.1). Also select “Console Application”, “C Project” and “Make default
Language” as the settings of your application.

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. By 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.

Naming a variable

It is better that you use meaningful names for your variables even if this causes them to become 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.

Getting input, Arrays, Character
Strings and Preprocessors


n previous lesson you learned about variables and printing output results on computer console. This
lesson discusses more about variables and adds important concepts on array of variables, strings of
characters and preprocessor commands. We will also learn more on getting input values from console
and printing output results after performing required calculations and processes. After this lesson you
should be able to develop programs which get input data from user, do simple calculations and print the
results on the output screen.
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

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
  CGI PROGRAMMING LABORATORY seminar ideas 1 596 08-10-2014, 08:16 AM
Last Post: OtlBY
  Object Oriented Programming with Java seminar paper 2 1,079 18-09-2014, 03:24 PM
Last Post: Radhika.m
  Fundamental Programming Structures in C pdf seminar projects maker 0 396 26-09-2013, 12:36 PM
Last Post: seminar projects maker
  DATA STRUCTURES USED IN NETWORK PROGRAMMING seminar projects maker 0 572 25-09-2013, 04:27 PM
Last Post: seminar projects maker
  Programming Language Theory ICS313 seminar projects maker 0 321 24-09-2013, 02:03 PM
Last Post: seminar projects maker
  Tutorial On Introduction to 8085 Architecture and Programming seminar projects maker 0 390 20-09-2013, 03:52 PM
Last Post: seminar projects maker
  UNIX SYSTEM PROGRAMMING pdf seminar projects maker 0 422 11-09-2013, 03:42 PM
Last Post: seminar projects maker
  Introduction to Microsoft Kinect Sensor Programming PPT study tips 0 412 10-09-2013, 12:02 PM
Last Post: study tips
  Socket Programming - UDP study tips 0 299 20-07-2013, 01:04 PM
Last Post: study tips
  Object-Oriented Programming with Java Report study tips 0 395 02-07-2013, 01:09 PM
Last Post: study tips