0% found this document useful (0 votes)
6 views9 pages

Paper 1

The document provides an overview of basic programming concepts in C, including definitions of algorithms, data types, and the structure of a C program. It explains the characteristics of higher-level programming languages and details operators, including increment and decrement operators. Additionally, it describes arrays as a way to store collections of similar data types.

Uploaded by

SHADOW GAMING
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Paper 1

The document provides an overview of basic programming concepts in C, including definitions of algorithms, data types, and the structure of a C program. It explains the characteristics of higher-level programming languages and details operators, including increment and decrement operators. Additionally, it describes arrays as a way to store collections of similar data types.

Uploaded by

SHADOW GAMING
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

M. Sc. (CA & IT) (Sem.

I) Examination November - 2019


Introduction to Programming Language
Paper - 103 (New Course) answers
1{a}

 Define :

 Algorithms : An algorithm is like a recipe for solving a problem


or doing a task. It's a set of clear, step-by-step instructions that a
computer (or a person) can follow.

 Range of int and float :

In C programming:

1. **int:** The range of an `int` depends on the system, but it's typically from -
2,147,483,648 to 2,147,483,647 for 32-bit systems and -
9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 for 64-bit systems.

2. **float:** The range of a `float` is approximately from 1.17549e-38 to


3.40282e+38. It's important to note that floating-point numbers have limited
precision, and using them for precise calculations may lead to rounding errors.

 Rules of Variable :
Sure, here are the basic rules for variables in C:

1. **Name them:** Give your variable a name, starting with a letter or underscore,
followed by letters, digits, or underscores.

2. **Be specific:** Choose a data type for your variable, like int for whole numbers or
float for decimals.

3. **No spaces:** Don't use spaces in variable names.


4. **First use, then declare:** Tell C you're going to use a variable by declaring it
before you use it.

5. **Stay consistent:** If you say it's an int, always use it like an int.

6. **Avoid special words:** Don't use words that C already knows, like int or float, as
variable names.

{b}

1) Explain Structure of C Program.

Certainly! Think of a C program like a recipe:

1. **Introduction (Optional):**

- Comments at the beginning to describe what the program does and who wrote it.

```c

/* My Simple Program

Author: Your Name */

```

2. **Ingredients (Header Files):**

- Include necessary "ingredients" (header files) like `#include <stdio.h>` for


input/output.

```c

#include <stdio.h>
```

3. **Instructions (main() Function):**

- The main part where the "instructions" (code) go. Every program starts executing
from here.

```c

int main() {

// Instructions go here

return 0; // Indicates everything went well

```

4. **Variables (Data Holders):**

- Declare "variables" (data holders) for age, height, or anything you need.

```c

int age = 25;

float height = 5.9;

```

5. **Show and Tell (Input/Output):**

- Use `printf()` to "show" things and `scanf()` to "tell" the program.

```c

printf("My age is %d\n", age);


```

6. **Decisions and Loops (Optional):**

- Use "decisions" (`if`, `else`) and "loops" (`while`, `for`) to control how the program
flows.

```c

if (age >= 18) {

printf("I'm an adult!\n");

} else {

printf("I'm a minor.\n");

```

7. **Functions (Optional):**

- Break down big tasks into "sub-recipes" (functions) for better organization.

```c

void sayHello() {

printf("Hello!\n");

```

8. **Clean Up (Return Statement):**

- End the main recipe with `return 0;` to say everything went smoothly.
```c

return 0;

```

This is a simple structure. As you get into more complex programs, you might use
more features and additional parts, but these basics remain.

(2) Explain characteristies of Higher-level languages

1. **Easy Talk:**

- Higher-level languages let programmers talk to the computer in a way that's more
like regular English, making it easier for people to write and understand code.

2. **No Machine Language Worries:**

- You don't have to worry much about the computer's nitty-gritty details. You can
focus on solving problems without getting into the low-level stuff like memory
addresses or registers.

3. **Move Around Easily:**

- Code written in higher-level languages can often move from one type of computer
to another without much hassle. It's like a recipe that you can use in different
kitchens.

4. **Easy to Fix and Change:**

- If you want to change or fix something in your program, it's generally easier. You
don't have to be a computer architecture expert to make adjustments.
5. **Lots of Pre-Made Tools:**

- There are tons of pre-made tools that come with higher-level languages. You don't
have to build everything from scratch. It's like having a well-stocked kitchen with lots
of utensils.

6. **Memory Management Help:**

- You get help managing computer memory. You don't need to worry too much
about exactly where in the computer's memory your program's data is stored.

7. **Building Blocks (Object-Oriented Programming):**

- Higher-level languages often let you build code in a way that's like playing with
building blocks. You can make reusable pieces (objects) and put them together easily.

8. **Less Tied to a Specific Computer:**

- Your program isn't stuck to one type of computer. It can work on different
machines without a complete rewrite. It's like making a dish that tastes good in many
kitchens.

9. **Read and Write Easily:**

- The code is easier to read and write. It's like writing a story or a set of instructions
that someone else (or future you) can easily understand.

10. **Gets Stuff Done Faster:**

- These languages are designed to help you get things done faster. You spend less
time dealing with computer details and more time solving real problems. It's like
having a faster and smarter assistant.
(3) Explain Data-types in brief.

Sure, let's talk about data types in C in a simple way:

1. **int (Integer):**
- This is for whole numbers, like 1, -5, or 1000. No decimals allowed.
```c
int age = 25;
```
2. **float (Floating Point):**
- For numbers with decimals, like 3.14 or -0.5.
```c
float height = 5.9;
```
3. **char (Character):**
- For individual characters, like 'A', '$', or '3'. Always in single quotes.
```c
char grade = 'A';
```
4. **double (Double Precision):**
- Similar to float but can hold more decimals. Use it for really precise numbers.
```c
double pi = 3.14159265359;
```
5. **_Bool (Boolean):**
- For true or false values. 0 is false, anything else is true.
```c
_Bool isRaining = 1; // true
```
6. **Array:**
- A collection of similar data. For example, an array of integers or characters.
```c
int numbers[5] = {1, 2, 3, 4, 5};
``
7. **String:**
- A sequence of characters. In C, it's an array of characters.
```c
char name[] = "John";
```
8. **Pointer:**
- A special type that holds the memory address of another variable
```c
int *pointerToAge = &age; // Holds the address of the variable 'age'
``

2 (a)
Define :
Operator

In C language, an operator is a symbol that represents a specific operation to be


performed on one or more operands. Operators are fundamental building blocks in
writing expressions and statements, allowing you to manipulate variables and values.

Increment and decreme operator

Certainly! In C programming:

1. **Increment Operator (`++`):**


- The increment operator adds 1 to the value of a variable.
```c
int count = 5;
count++; // Now 'count' is 6
```
- It can also be used before the variable (`++count`). Both `count++` and `++count` increase the value, but
they can behave differently in certain situations.

2. **Decrement Operator (`--`):**


- The decrement operator subtracts 1 from the value of a variable.
```c
int lives = 3;
lives--; // Now 'lives' is 2
```
- Like the increment operator, the decrement operator can also be used before the variable (`--lives`).

These operators are handy for counting, looping through things, or generally manipulating variables by
changing their values in a simple and concise way.

Array

**Array:**
- An array is like a numbered line of storage boxes.
- Each box holds a similar type of thing (number, text, etc.).
- You can easily find or change what's in a box by using its number.
- Great for keeping organized collections of stuff in a program.

You might also like