Computer programming
Explain each
of the following
·
Header
files
·
Application
software
·
Machine
language
Header files: Header file is a file containing C declaration
and macro definition to be shared between several source files.
Application software:
Application software
designed to specific task for user. Such software directs the computer to
execute commands given by user and may be side to includes any program that
processes data for a user.
System software: System software is a type of computer program
that is designed to run a computer’s hardware and application programs.
Machine language:
Machine language is the
language understood by a computer. All programs and programming languages
eventually generate or run programs in machine language.
Main memory: Main memory stores instruction and data while
a program is running.
Secondary memory: Stores instruction and data between
sessions. A file stores data or instructions in secondary memory.
Random access: Usually called RAM. Computer can directly
access any memory location.
ROM: Read only memory (ROM) is a type of computer
storage containing non-volatile permanent data that normally can only be read
not written to.
What do you
mean by data type? Explain various data types used in C.
Data type: A data type specifies the type of data that a
variable can store such as integer, floating, character etc.
Types of data types
in C
Here are the five major categories into which
data types are divided in C language:
|
Data Type |
Example of Data Type |
|
Floating-point, integer, double, character. |
|
|
Union, structure, array, etc. |
|
|
Enums |
|
|
Void Data Type |
Empty Value |
|
Bool Type |
True or False |
The basic data types are also known as the
primary data types in C programming.
What are keywords?
Keywords are predefined and specific reserved
words which hold special meaning.
Example: auto, int, else, if, short, union,
long, for, return, float, do, goto, while, char, case, void etc.
What are C tokens and
its types?
C
tokens: We can
define the token as the smallest individual element in C. Tokens in C is the
most important element to be used in creating a program in C.
C tokens
are six types. They are
·
Keywords
– int, if
·
Identifiers-
main, total
·
Constants-
10,20
·
Strings-
(-total, -held)
·
Special
symbols- (), {}
·
Operators-
+, /, *, -
What are
identifiers?
A particular name
generated by the programmer to define a variable, structure, class or function
is called an identifier.
|
Name |
Remark |
|
_A9 |
Valid |
|
Temp. bar |
Invalid as it contains special character
other than underscore |
|
void |
Invalid as it is a keyword |
Difference between keyword and identifier
|
Keyword |
Identifier |
|
Keywords are predefined and specifies
reserved words, which hold special meaning. |
A particular name generated by the
programmer to define a variable, structure, class or function is called
identifier. |
|
It defines the type of entity. |
It classifies the name of the entity. |
|
It helps in defining a particular property
that subsists in a computer language. |
It helps in locating the name of the
entity. |
|
It should be lowercase. |
It can be both upper and lowercase. |
|
Int, auto, if, else, float, double all are
example of keywords. |
Test, high_ speed, are example of
identifiers |
Difference
between compiler and interpreter?
|
Compiler |
Interpreter |
|
Compiler is a translator which takes input
high level language and produces an out-put low level language machine or assembly
language. |
Translates the program one statement at a
time. |
|
As it the code in one go, the errors are
shown at the end together. |
Considering it scans code one line at a
time. |
|
It converts the source code into object
code. |
It does not convert source code into object
code instead it scans it line by line. |
|
It is more efficient |
It is less efficient. |
|
CPU utilization is more. |
CPU utilization is less |
|
C, C++, C# etc. are programming languages
that are compiler based. |
Python, Ruby, MATLAB etc. are programming
languages that are interpreter based. |
What is ASCII
value? Explain the ASCII value of ‘a’ with an example.
The ascii value represent the character variable in numbers, and each character variable is assigned with some number range from 0 to 127.
Example 1:
Input:
Enter character: a
Output: ASCII is: 97
Example 2:
Input:
Enter character: a
Output: ASCII is: 65
Program:
#include<stdio.h>
int main ()
{
char ch;
//input character
printf("Enter
the character: ");
scanf("%c", &ch);
printf("ASCII
is = %d\n", ch);
return 0;
}
Basic
structure of C programming?
A C program
basically consists of the following parts
·
Preprocessor
commands
·
Functions
·
Variables
·
Statements
& expressions
·
Comments
Example:
#include<stdio.h>
Int main ()
{
/* program in C*/
printf( “hello”);
return 0;
}
Explain
·
The
first line of the program #include <stdio.h> is a processor command,
which tell a C compiler to include stdio.h file before going to actual
compilation.
·
The next
line int main () is the main function where the program execution beings.
·
The line /*…*/ will be ignored by the compiler
and it has been put to add additional comments in the program.
·
The next line printf(...) is another function
available in C which causes the message "Hello, World!" to be
displayed on the screen.
· The next line return0; terminates the main () function and returns the value 0.
What is header
file in C? what is stranded header file in C?
Header files: Header file is a file containing C declaration
and macro definition to be shared between several source files.
Stranded header
file in C: In C programming
a stranded header file refers to a header file that is included in a C source
file but none of its declaration or function are actually used in that source
file.
What is data
type? Why do we need it in programming? Explain any three basic data types with
example?
Data type: A data type specifies the type of data that a
variable can store such as integer, floating, character etc.
Programming
languages use data types to represent different kind of data types such as
numbers, characters, string and array and they determine how the data can be
stored and manipulated. Data types also ensure that the program behaves
consistently and correctly by enforcing rules on how data can used.
Here are three basic
data types with examples:
Integer: This data type represents whole numbers
without any decimal place. Example- 1,2,3,4, and so on
String: This data type represents a sequence of
character, such as letters, numbers, and symbols. Example- “hello”, “world”,
“123”,”@#$%”
Boolean: This data type represents logical value that
can be either true or false. Example- include true and false.


0 Comments