PSP Solution

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Basic structure of c program with example

//BASIC STRUCTURE OF C PROGRAM WITH EXAMPLE

#include <stdio.h>// these are header files which contains some predefined functions in
them

#include <conio.h>// .h extension defines them as a header file

void main()// is a function where argument is passed and program begins

{//scope

int a; // variable declaration

printf("Enter the number : "); // this function is used to display the output

scanf("%d", &a); // this function is used for inputting the value

getch(); // it pauses the output console.

} //scope

Explain flowchart draw a flowchart to calculate the average of two numbers.

Flowchart is a pictorial representation of programs. It represents process using different


shapes like oval, rectangle and arrows to show linkage between data flow.

What is algorithm? Design an algorithm to add two numbers.

An algorithm is step by step procedures or set of rues that defines how program is to be
executed. It is often

Without regard to the underlying programming language.

Step 1: Start

Step 2: Declare three integer variable a,b,c.


Step3: Initialise value of a and b.

Step4: Add values of a and b.

Step5: Store the output of step 4 in c.

Step6: Print c.

Step7: Stop.

Difference between Primary Memory and Secondary Memory.

Explain different type of tokens and give examples of each

Tokens in C language are the smallest elements or the building blocks used to construct a C

program. C tokens are of 5 types, and they are classified as: Identifiers, Keywords,

Constants, Operators, Punctuations.

Keywords - Keywords are predefined, reserved words in C and each of which is associated with specific

features. These words help us to use the functionality of C language. They have special

meaning to the compilers.

Identifiers - Each program element in C programming is known as an identifier. They are used for naming

of variables, functions, array etc. These are user-defined names which consist of alphabets,

number, underscore ‘_’

Literals - Literals are the Constant values that are assigned to the constant variables. Literals

represent fixed values that cannot be modified.

Operators - An operator is simply a symbol that is used to perform operations. There can be many types

of operations like arithmetic, logical, bitwise, etc.


Explain different types of programming language
Different type of Programming languages are :-
(i)Low Level Language:
It is a machine level language. It is a machine level. It is a programming language that deals with
Computer's hardware also called Binary Language. It is made up of binary numbers or bits that a
computer can understand.
(Ii) Assembly Level Language:
Assembly language, also known as assembler language, is a low-level programming language
that’s designed to communicate instructions with specific computer hardware and direct the
flow of information
(i) High Level Language:
A high-level language is any programming language that enables development of a program in a
much more user-friendly programming context and is generally independent of the computer's
hardware architecture. It needs compiler or interpreter to translate into low level language.
Difference between user defined and library function.
What is structure? Explain the c syntax of structure declaration with example.

Explain the difference between array and structure .

You might also like