0% found this document useful (0 votes)
10 views5 pages

Vaibhavi C# 2310

Uploaded by

vcharankhilare
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)
10 views5 pages

Vaibhavi C# 2310

Uploaded by

vcharankhilare
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/ 5

Q1. Why C language is called low/middle level language and C# as high level language?

Both High level language and low level language are the programming languages’s types. The main
difference between high level language and low level language is that, Programmers can easily
understand or interpret or compile the high level language in comparison of machine.

C is a low-level language that gives developers direct control over memory management and
memory resources, while C# is a higher-level language with object-oriented features and automatic
memory management and garbage collection.

C is called a high level, compiler language.

The plan of high-level computer language is to deliver an easy and natural way of giving a program of
commands to a computer.

C# is derived from C programming language, alike to Java, C# is object-oriented, comes with a wide
class library, and chains exception handling, multiple types of polymorphism, and separation of
interfaces from implementations.

The language is proposed for use in developing software components appropriate for deployment in
distributed environments.

The C# language is deliberate to be a straightforward, modern, general-purpose, object-oriented


programming language.

Testing frameworks like NUnit11 make C# agreeable to test-driven development, so a good language
for use with Extreme Programming.

C#, garbage collection is managed by Common Language Runtime (CLR).

C# features with powerful development tools, multi-platform support, and generics, formulate C# a
superior choice for many types of software development projects as below.

Q2. What are the features of C, C++, C# languages?

C language Features:

C is a simple language in the sense that it provides a structured approach (to break the problem into
parts), the rich set of library functions, data types, etc.

Unlike assembly language, c programs can be executed on different machines with some machine
specific changes. Therefore, C is a machine independent language.

C is intended to do low-level programming. It is used to develop system applications such as kernel,


driver, etc. It also supports the features of a high-level language. That is why it is known as mid-level
language.

It supports the feature of dynamic memory allocation. In C language, we can free the allocated
memory at any time by calling the free() function.

C++ language Features:


C++ includes both low-level programming and high-level language so it is known as a mid-level and
intermediate programming language. It is used to develop system applications such as kernel, driver,
etc.

C++ is a structured programming language. In this we can divide the program into several parts using
functions.

C++ provides a lot of inbuilt functions that make the development fast. Following are the libraries
used in C++ programming are:

C++ provides very efficient management techniques. The various memory management operators
help save the memory and improve the program's efficiency. These operators allocate and deallocate
memory at run time. Some common memory management operators available C++ are new, delete
etc.

C++ programs tend to be compact and run quickly. Hence the compilation and execution time of the
C++ language is fast.

C# language Features:

C# is a simple language in the sense that it provides structured approach (to break the problem into
parts), rich set of library functions, data types etc.

C# programming is based upon the current trend and it is very powerful and simple for building
scalable, interoperable and robust applications.

C# is object oriented programming language. OOPs makes development and maintenance easier
where as in Procedure-oriented programming language it is not easy to manage if code grows as
project size grow.

C# type safe code can only access the memory location that it has permission to execute. Therefore it
improves a security of the program.

Interoperability process enables the C# programs to do almost anything that a native C++ application
can do.

Q3. What are the Datatypes supported for C, C++, C# Languages?

C DataTypes:

int: Represents integers.

float: Represents single-precision floating-point numbers.

double: Represents double-precision floating-point numbers.

char: Represents individual characters.

_Bool: Represents boolean values (0 for false, non-zero for true).

void: Represents an empty data type and is often used for functions that do not return a value.
short: Represents short integers. long: Represents long integers. long long: Represents long long
integers.

signed: Indicates a signed integer. unsigned: Indicates an unsigned integer. enum: Represents
enumerated types.

struct: Defines user-defined composite data types. union: Defines a composite data type that can
hold any one of its members.

C++ DataTypes:

int: Represents integers.

float: Represents single-precision floating-point numbers.

double: Represents double-precision floating-point numbers.

char: Represents individual characters.

_Bool: Represents boolean values (0 for false, non-zero for true).

void: Represents an empty data type and is often used for functions that do not return a value.

bool: Represents Boolean values (true or false).

string: Represents a sequence of characters.

class: Allows you to create user-defined data types through classes and structures.

C++ DataTypes:

C# is a different language from C and C++, but it shares some data types with them. Common data
types in C# include:

int: Represents 32-bit signed integers.

float: Represents single-precision floating-point numbers.

double: Represents double-precision floating-point numbers.

char: Represents individual characters.

bool: Represents Boolean values (true or false).

string: Represents a sequence of characters.

byte: Represents 8-bit unsigned integers.

short: Represents 16-bit signed integers.

long: Represents 64-bit signed integers.

decimal: Represents high-precision decimal numbers.

object: The base class for all types in C#.


Q4. What are the pointers and their use ? and how pointers works

Pointers are a fundamental concept in programming languages like C, C++, and other low-level
languages. They allow you to work directly with memory addresses, which can be powerful but also
come with certain risks. Pointers are used for a variety of purposes, including:

Dynamic Memory Allocation: Pointers are commonly used to allocate and deallocate memory
dynamically. For example, in C and C++, you can use malloc() and free() functions to allocate and
release memory using pointers.

Efficient Data Access: Pointers provide a way to access and manipulate data efficiently by working
directly with memory addresses. This is particularly useful for large data structures and arrays.

Function Parameters: Pointers can be used to pass data by reference to functions, allowing a function
to modify the original data directly.

Data Structures: In languages like C and C++, pointers are used to create complex data structures
such as linked lists, trees, and graphs.

Low-Level and Hardware Access: Pointers are essential when you need to interact with hardware or
work with low-level programming, such as device drivers and system programming.

Arrays and Strings: Arrays in C and C++ are essentially a type of pointer that points to the first
element of the array. Strings in C are typically represented as arrays of characters, making use of
pointers for manipulation.

How Pointers Work:

Pointers store memory addresses, allowing you to access the data stored at that location. Here's a
basic overview of how pointers work:

Declaration: To declare a pointer, you use an asterisk (*) before the variable name. For example:

int *ptr;

Initialization: Pointers can be initialized with the memory address of another variable:

int x = 42;

int *ptr = &x; // ptr now points to the memory location of x

Dereferencing: To access the value at the memory location pointed to by a pointer, you use the
asterisk (*) again. This is known as dereferencing

int value = *ptr; // value is now 42 (the value at the memory location pointed to by ptr)

Arithmetic: You can perform arithmetic operations on pointers. For example, you can increment or
decrement a pointer, which moves it to the next or previous memory location:

ptr++; // Moves ptr to the next memory location

Pointer to Functions: Pointers can also be used to store addresses of functions, enabling you to call
functions indirectly.
Pointer Safety: Pointers must be used with caution. Improper use can lead to memory leaks,
segmentation faults, and undefined behavior. It's essential to ensure that pointers are initialized and
used correctly.

Understanding pointers is crucial for low-level programming and for working with languages that
provide more direct control over memory management. However, they also introduce a level of
complexity and potential for errors, so they require careful handling.

Q5. Difference Between C, C++, C#?

C Language C++ Language C# Language


In c language Manual memory In C++ memory management is In C# memory management is
management performed. performed manually by the performed automatically by
programmer. If a programmer the garbage collector. If the
creates an object then he is programmer creates an object
responsible to destroy that and after the completion of
object after the completion of that object’s task the garbage
that object’s task. collector will automatically
delete that object.
C is platform dependent C++ code can be run on any C# code is windows specific.
language. platform. C++ is used where Although Microsoft is working
the application needed to to make it global but till now
directly communicate with the major system does not
hardware. provide support for C#.

C does not supports multiple C++ support multiple C# does not support any
inheritance. inheritance through classes. multiple inheritances through
Means that a class can extend classes.
more than one class at a time.
Pointers are one of the things In C++ pointers can be used In C# pointers can be used only
that make C stand out from anywhere in the program. in unsafe mode.
other programming languages
C language is Est to learn and C++ includes very complex C# is quite easy because it has
very Easy language. features. the well-defined hierarchy of
classes.
C is a structural or procedural C++ is not a pure object- C# is a pure object-oriented
programming language is not oriented programming programming language.
object oriented. language due to the primitive
data types.
C does not have garbage C++ do not support garbage Garbage collection is
collection. collection. supported by C#

You might also like