0% found this document useful (0 votes)
4 views4 pages

C Tutorial Day 6

The document outlines the basic programming structure in C, detailing three types of constructs: sequential, condition and branching, and condition and looping. It explains how to write a simple C program, including the use of header files, function definitions, and the compilation process using TC IDE. Several programming exercises are provided to practice basic C programming skills.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

C Tutorial Day 6

The document outlines the basic programming structure in C, detailing three types of constructs: sequential, condition and branching, and condition and looping. It explains how to write a simple C program, including the use of header files, function definitions, and the compilation process using TC IDE. Several programming exercises are provided to practice basic C programming skills.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Programming With C-Basic Programming Structure

There are three types of programming construct:


1. Sequential
2. Condition and Branching
3. Condition and Looping

The thing that we must know, before writing sequential program are:
1. How to include required header files? Header files contain predefined functions used in the program.
Such as scanf() and printf() is a function which is defined in stdio.h header file, which is included in the
program using #include preprocessor directive as
#include <stdio.h>
2. C program is a collection of function programs, in which one function must have a name main from
where program starts and ends. Default return of main () function is int. Since it is main function hence
it will not return any data type so it is better to write void main() instead of main (). Function must be
written in block which is created using curly braces { program segment }.
void main()
{
statements;
}

Created and verified By: B. K. Deepak 49


Dated:20/12/2004
Rev:00
Programming With C-Basic Programming Structure

3. The block of function will consist of data declaration statements, printf() statements, scanf() state-
ments, assignment statements.
4. Comment line. We can specify comment lines using /* This is comment line */. The lines written in side
the /* and */ are treated as comment or remarks.

Now we are able to write sequential programming as follows.


Q.1: Write a program to show a welcome message on the screen.
/***********************
* First Program *
***********************/
#include <stdio.h>
void main()
{
printf(”Welcome to the world of Programming”);
} /* end of Program */

We have to use TC (Turbo Compiler) IDE to write the source code written above and save the program in
proper directory and name it as “welcome.c”.

Created and verified By: B. K. Deepak 50


Dated:20/12/2004
Rev:00
Programming With C-Basic Programming Structure

TC IDE will also provide the facility to compile the code written above. In compilation there may be error if
any reported by the compiler. Then we have to debug the source code. The program will compile successful-
ly only when there will be no error. After compilation compiler will generate an object file as an output, have
extension .obj.
TC IDE provide linking facility through which compiled program will be linked through system library and gen-
erate system specific standalone executable program having extension .exe.
TC IDE also provides facility to run the program.
Q2: Write a program that accepts two integer inputs and calculate their sum and show the results.
/* Second program */
#include <stdio.h>
void main()
{
int a,b,sum;
printf(”\n\tEnter two integer number a and b : ”);
scanf(”%d %d”, &a , &b);
sum=a+b;
printf(”\n\tSum : %d”, sum);
}

Created and verified By: B. K. Deepak 51


Dated:20/12/2004
Rev:00
Programming With C-Basic Programming Structure

Q:3 Write a program to find out area of a circle when radius will be provided through keyboard.
Q:4 WAP to find out area of triangle and its perimeter when three sides will be given through keyboard.
Q:5 WAP to accept temperature in degree Celsius and convert it in degree Fahrenheit.
Q:6 WAP to accept temperature in degree Fahrenheit and convert it in degree Celsius.
Q:6 WAP to accept a four digit integer number and find out sum of their individual digit.
Q:7 WAP to sum first 10 integer numbers.
Q:8 WAP to swap(exchange) the value of a and b.
Q:9 WAP to swap(exchange) the value of a and b without using third variable.

Created and verified By: B. K. Deepak 52


Dated:20/12/2004
Rev:00

You might also like