Welcome !!

NICETECHVIDYA

Tutorials

Web Designs

You are welcome to Aptech Designers, designed by Pratik from Nepal.

Creativity is my passion. Logo describes your details about company.

Graphics Design needs vision to create yours unique digital concept.

Responsive and All Browser Compatible Dynamic Web Layouts our target.

Home Python C Language J A V A Our Courses
This WebSite is under Construction....

Thursday 10 March 2022

10.Executing a C program and some modifications

 

Executing a C program:

1. Open the C-IDE (Integrated Development Environment) by double click on “short cut to tc” which is on desktop.

 

 

 

 


2. To create a new file select File (Alt+F), New (N) [F is the hot key to File option and N is the hot key to New].

 

 

 

 

 

 

 

 

 

 

 

 


 


3. Type the program.

 

 

 

 

 

 

 

 

 

 

 


 


4. Save the program by selecting File (Alt+F), Save (S). or select F2 (It is the short-cut to save option)

Here the name of C program is saved with .c extension. (C automatically takes .c extension if we don’t give)

 

 

 

 

 

 

 

 

 

 


 

 

5. Executing the program.

Press Ctrl  +  F9 to execute the program

 
 

 

 

 


6. Viewing the output.

 

 

 

 

 

 

 

 

 

 


  1. Output of second execution

 

 

 

 

 

 

 

 

 


Some modifications:

 

The output of first execution is remaining there, even after the completion of second execution. It may be confusing output while experimenting with the program. We can use “clrscr();” to clear the output generated by previous execution.

 

“getch();“ can be used to immediately display the output instead of using Alt+F5 to view the output.

 

In turboc2, writing  #include<stdio.h> at the beginning of the program is not mandatory to use printf(), scanf(), clrscr(), getch(). Because these are the default functions of turboc2 compiler.

 

Modifying the structure of C program (Turboc2 only):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Comparison among the BASIC and C programming:

 

Specification:

Take two numbers and print the sum of them

 

Programs:

Basic Progam

 

fir=45

sec=50

sum=fir+sec

print sum

 

 

C Progam



#include<stdio.h>
void main( )
{
int fir, sec, sum;
clrscr();
fir=45;
sec=50;
sum=fir+sec;
printf(“Sum of two numbers %d”,sum);
getch();    
}
 
 

 

 

 

 

 

 

 

 

 

 

 

 

 


Specification:

Take the length, breadth of rectangle and print the area, perimeter.

 

Programs:

C Progam

 


#include<stdio.h>
void main( )
{
int l, b, area, peri;
clrscr();
l=12;
b=34;
area=l*b;
peri=2*(l+b);
printf(“Area of rectangle %d”,area);
printf(“\nPerimeter of rectangle %d”,peri);
getch();    
}


 

Basic Progam

 

l=12

b=34

area=l*b

peri=2*(l+b)

print area

print peri

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Specification:

Take the price, quantity of a product and print the bill.

 

Program:

C Progam


#include<stdio.h>
void main( )
{
int qty;
float price,bill;
clrscr();
price=25.75;
qty=15;
bill=price*qty;
printf(“Total bill %f”,bill);   
getch();    
}
 

Basic Progam

 

price=25.75;

qty=15;

bill=price*qty

print bill

 

 
 

 

 

 

 

0 comments:

Post a Comment