Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Problem-Solving Using C language

Beoordeling
-
Verkocht
-
Pagina's
30
Geüpload op
16-01-2025
Geschreven in
2022/2023

Problem-solving Using C language provides a comprehensive overview of the language, covering its history, features, and practical applications. It begins with an introduction to C, explaining its significance in system programming, embedded systems, and software development. The document details the evolution of C from its inception by Dennis Ritchie in 1972 to modern standards like C99 and C11. It includes a section on setting up a C programming environment, followed by a structured breakdown of C syntax, data types, operators, control flow statements, functions, arrays, strings, pointers, and memory management. Advanced topics such as structures, unions, enumerations, and file handling are covered to give a complete understanding of C programming. The document also explains debugging techniques, error handling, and best practices for writing efficient C programs. It concludes with real-world applications of C, a summary of key concepts, and references to additional learning resources. With detailed explanations, code examples, and structured content, the document serves as a solid foundation for beginners while providing insights for advanced learners.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

UNIT - 1


→ COMPUTER: It is an electronic machine which accepts data as its input then process it by
doing some kind of manipulations and produce the output in a desired format. Technically a
computer is a high speed electronic data processing machine.

BLOCK DIAGRAM OF A COMPUTER:




The computer consists of four blocks, they are

1. Input Unit
2. Central Processing Unit
3. Output Unit
4. Auxiliary Memory Unit

Input unit: Input unit is provided for man-to-machine communication. It accepts data in human
readable form and converts it into machine readable form and sends it to CPU. A computer may
have one or more input devices, depending upon its type, size and use. Keyboard and mouse are
most commonly used input devices.
Central Processing Unit: It consists of three units
a) Control Unit (CU)
b) Arithmetic Logic Unit (ALU) and
c) Memory Unit (MU).
The main function of CPU is:
1. Control the sequence of operation as per the stored instructions
2. Issue commands to all parts of the computer
3. Stores data and instructions
4. Process the data and sends results to output.

Control Unit: The control unit controls and co-ordinates all operations of the CPU, Input and
output devices.
1. It gives commands to transfer data from input unit to memory unit, and arithmetic logic
unit.
2. It stores the program in the memory, accesses instructions one by one, issues appropriate
commands to other units according the instructions.
3. It transfers the results from ALU to the memory unit and output unit.
4. It fetches the required instructions from the main memory, and interprets it by sending
appropriate signals to the concerned hardware device.

PROBLEM SOLVING USING C VVIT, CSE Dept. Page 1

, UNIT - 1


Arithmetic and Logic Unit: It carries out all arithmetic operations like addition, subtraction,
multiplication and division. Also it performs all logical operations.
Memory Unit: It is used to store programs and data. It is mainly two types, they are:
1. Main memory or primary memory or Immediate Access Storage (IAS), which is part of
the CPU.
2. Auxiliary memory or secondary storage, which is external to the CPU.

Output unit: Output unit is provided for machine-to-man communication. It receives the
information from CPU in machine readable form and presents it to the user in a desired form. A
computer may have one or more output devices depending upon use. The Visual Display Unit
(VDU) and printers are most commonly used devices.


Structure of C Program: A „C‟ program is a group of building blocks called functions. A
function is a subroutine that may include one or more statements designed to perform a specific
task. To write a C program we first create functions and then put them together. Any C program
may contain one or more sections as shown in the figure.

Documentation Section //optional
Link Section //optional
Definition Section //optional
Global declaration Section //optional
Main( ) function section //must
{
Declaration part
Executable part
}
Subprogram Section //optional
Function -1
Function-2


Function-n


Documentation Section: To enhance the readability of the program, programmers can provide
comments about the program in this section. The comments are included between the delimiters
/* and */. These statements are not executable rather they are ignored by the compiler. Comments
can be used anywhere in the program.

Link Section: This section instructs the compiler to link functions from the „C‟ library. Library
functions are grouped category wise and stored in different files known as header files. If we want
to access the functions stored in the library, it is necessary to tell the compiler about the files to be
accessed. This can be done through a preprocessor directive #include <filename>

Ex: The statement #include<stdio.h> instructs the compiler to include the file “stdio.h” before
starting the compiling step.
PROBLEM SOLVING USING C VVIT, CSE Dept. Page 2

, UNIT - 1



Definition Section: It is used to define symbolic constants and to define macros. The preprocessor
directive #define is used for the purpose.

Ex: # define PI 3.14 assigns the symbolic name PI to the constant value 3.14

Global Declaration Section: There are two places where variables and functions are declared –
inside a function or outside all functions. Variables declared outside all functions are called global
variables and are declared in this section.

Main( ) Function Section: The main( ) is a special function used by the C system to tell the
computer where the program starts. Every program must have exactly one main function. This
section has two parts

a) Declaration part b) execution part

The declaration part declares all the variables that are used in the executable part. There is at
least one statement in the executable part. These two parts can appear between the opening and
closing braces. In all C programs execution begins at this opening brace and ends at this closing
brace. The closing brace of this function is the logical end of the program. All the declaration and
executable statements end with a semicolon.

Subprogram Section: This section contains user defined functions that are used in the main
function. User defined functions are generally placed immediately after the main function.

All Sections except the main function section may be absent when they are not required.

Example Program:
/* A Sample C program */
#include <stdio.h>
main( )
{
/* prints the string*/
Printf(“ welcome to VVIT”);
}

Example Program 2:
/* A Sample C program */ /* documentation section*/
#include <stdio.h> /* Link section*/
main( ) /*main( ) function section begins*/
{
int length, breadth, area; /*local variables declaration part*/
scanf(“%d”, &length);
scanf(“%d”, &breadth);
area = length * breadth;
printf(“area of the rectangle = %d”,area);
} /* main() function section ends*/
PROBLEM SOLVING USING C VVIT, CSE Dept. Page 3

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
16 januari 2025
Aantal pagina's
30
Geschreven in
2022/2023
Type
College aantekeningen
Docent(en)
Vijaya anandaratnam
Bevat
Alle colleges

Onderwerpen

$10.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
srilathalakshmisetty04

Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
srilathalakshmisetty04 Vasireddy Venkatadri Institute of Technology
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
1 jaar
Aantal volgers
0
Documenten
5
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen