Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CUSAT syllabus #64

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/AbhinavSanal"><img src="https://avatars.githubusercontent.com/u/112882054?v=4?s=100" width="100px;" alt="" /><br /><sub><b>Abhinav Sanal</b></sub></a><br /><a href="https://github.com/gtech-mulearn/WikiSyllabus/commits?author=AbhinavSanal" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/CLiz17"><img src="https://avatars.githubusercontent.com/u/68838221?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chaitanya Liz</b></sub></a><br /><a href="https://github.com/gtechatfg/WikiSyllabus/commits?author=CLiz17" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/umavm"><img src="https://avatars.githubusercontent.com/u/80395383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Uma V Menon</b></sub></a><br /><a href="https://github.com/gtechatfg/WikiSyllabus/commits?author=umavm" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Angelrose19"><img src="https://avatars.githubusercontent.com/u/84169295?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Angel Rose</b></sub></a><br /><a href="https://github.com/gtechatfg/WikiSyllabus/commits?author=Angelrose19" title="Code">💻</a></td>
Expand Down
25 changes: 25 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
- [](WikiSyllabus/SUMMARY.md)
- [CUSAT](./WikiSyllabus/CUSAT/SUMMARY.md)
- [2023_Scheme](./WikiSyllabus/CUSAT/2023_Scheme/SUMMARY.md)
- [S1 & S2](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/SUMMARY.md)
- [23-200-0106B](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/SUMMARY.md)
- [Introduction to C Programming](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/1intro.md)
- [Variables and Keywords](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/2variables_keywords.md)
- [Datatypes](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/3datatypes.md)
- [Constants](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/4constants.md)
- [Operators](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/5operators.md)
- [Control Statements](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/6control_statements.md)
- [goto statement](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/7goto.md)
- [Switch Statement](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/8switch_statement.md)
- [break Statement](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/9break.md)
- [Continue Statement](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/10continue.md)
- [Loops](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/11loops.md)
- [Functions](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/12functions.md)
- [Calling Functions](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/13function_arguments.md)
- [Library Functions](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/14library_functions.md)
- [Recursion](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/15recursion.md)
- [Storage Classes](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/16storage_classes.md)
- [Array](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/17arrays.md)
- [Pointers](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/18pointer_arithmetic.md)
- [Pointer to Pointer](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/19pointer_to_pointer.md)
- [Strings](./WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/20strings.md)

- [KTU](./WikiSyllabus/KTU/SUMMARY.md)
- [2019_Scheme](./WikiSyllabus/KTU/2019_Scheme/SUMMARY.md)
- [S1 & S2](./WikiSyllabus/KTU/2019_Scheme/S1-S2/SUMMARY.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# continue Statement

Continue is also a loop control statement just like the break statement. Continue statement is opposite to that of break _statement_, instead of terminating the loop, it forces to execute the next iteration of the loop.

As the name suggest the continue statement forces the loop to continue or execute the next iteration. When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and next iteration of the loop will begin.

![](assets/continue_syntax.png)

**Example** :

Consider the situation when you need to write a program which prints number from 1 to 10 and but not 6. It is specified that you have to do this using loop and only one loop is allowed to use.

Here comes the usage of continue statement. What we can do here is we can run a loop from 1 to 10 and every time we have to compare the value of iterator with 6. If it is equal to 6 we will use the _continue_ statement to continue to next iteration without printing anything otherwise we will print the value.

Below is the implementation of the above idea:

![](assets/continue_example.png)

**Output:**

![](assets/continue_ex_output.png)

The _continue_ statement can be used with any other loop also like while or do while in a similar way as it is used with for loop above.

173 changes: 173 additions & 0 deletions src/WikiSyllabus/CUSAT/2023_Scheme/S1-S2/23-200-0106B/11loops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Loops

Looping Statements in C execute the sequence of statements many times until the stated condition becomes false. A loop in C consists of two parts, a body of a loop and a control statement. The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. The purpose of the C loop is to repeat the same code a number of times.

## Types of Loops in C

Depending upon the position of a control statement in a program, looping statement in C is classified into two types:

1. Entry controlled loop

2. Exit controlled loop

### 1. Entry controlled loop

In an entry control loop in C, a condition is checked before executing the body of a loop. It is also called as a pre-checking loop.

In an exit controlled loop, a condition is checked after executing the body of a loop. It is also called as a post-checking loop.

![](assets/entryloopflow.png)

&#39;C&#39; programming language provides us with three types of loop constructs:

1. The while loop

2. The do-while loop

3. The for loop

| **Sr. No.** | **Loop Type** | **Description** |
| --- | --- | --- |
| 1. | While Loop | In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. |
| --- | --- | --- |
| 2. | Do-While Loop | In a do...while loop, the condition is always executed after the body of a loop. It is also called an exit-controlled loop. |
| 3. | For Loop | In a for loop, the initial value is performed only once, then the condition tests and compares the counter to a fixed value after each iteration, stopping the for loop when false is returned. |

## While Loop in C

A while loop is the most straightforward looping structure. While loop syntax in C programming language is as follows:

Syntax of While Loop in C:

while (condition) {

statements;

}

It is an entry-controlled loop. In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. After the body of a loop is executed then control again goes back at the beginning, and the condition is checked if it is true, the same process is executed until the condition becomes false. Once the condition becomes false, the control goes out of the loop.

After exiting the loop, the control goes to the statements which are immediately after the loop. The body of a loop can contain more than one statement. If it contains only one statement, then the curly braces are not compulsory. It is a good practice though to use the curly braces even we have a single statement in the body.

Following program illustrates while loop in C programming example:

#include<stdio.h>
#include<conio.h>
int main()
{
int num=1; //initializing the variable
while(num<=10) //while loop with condition
{
printf("%d\n",num);
num++; //incrementing operation
}
return 0;
}
Output:

1
2
3
4
5
6
7
8
9
10

## **Do-While loop in C**

A do...while loop in C is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit-controlled loop.

Syntax of do while loop in C programming language is as follows:

**Syntax of Do-While Loop in C:**

do {

statements

} while (expression);

As we saw in a while loop, the body is executed if and only if the condition is true. In some cases, we have to execute a body of the loop at least once even if the condition is false. This type of operation can be achieved by using a do-while loop.

In the do-while loop, the body of a loop is always executed at least once. After the body is executed, then it checks the condition. If the condition is true, then it will again execute the body of a loop otherwise control is transferred out of the loop.

Similar to the while loop, once the control goes out of the loop the statements which are immediately after the loop is executed.

The following loop program in C illustrates the working of a do-while loop:

Below is a do-while loop in C example to print a table of number 2:

#include<stdio.h>
#include<conio.h>
int main()
{
int num=1; //initializing the variable
do //do-while loop
{
printf("%d\n",2*num);
num++; //incrementing operation
}while(num<=10);
return 0;
}
Output:

2
4
6
8
10
12
14
16
18
20


## For loop in C

A for loop is a more efficient loop structure in &#39;C&#39; programming. The general structure of for loop syntax in C is as follows:

### Syntax of For Loop in C:

for (initial value; condition; incrementation or decrementation )

{

statements;

}

- The initial value of the for loop is performed only once.
- The condition is a Boolean expression that tests and compares the counter to a fixed value after each iteration, stopping the for loop when false is returned.
- The incrementation/decrementation increases (or decreases) the counter by a set value.

Following program illustrates the for loop in C programming example:

#include<stdio.h>
int main()
{
int number;
for(number=1;number<=10;number++) //for loop to print 1-10 numbers
{
printf("%d\n",number); //to print the number
}
return 0;
}
Output:

1
2
3
4
5
6
7
8
9
10



Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Functions

#### Function is a self-contained block of statements that can be executed repeatedly whenever we need it.

## **Benefits of using the function in C**

1. The function provides modularity.
2. The function provides reusable code.
3. In large programs, debugging and editing tasks is easy with the use of functions.
4. The program can be modularized into smaller parts.
5. Separate function independently can be developed according to the needs.

## **There are two types of functions in C**

```text
## **Built-in(Library) Functions**

The system provided these functions and stored in the library. Therefore it is also called Library Functions.
e.g. scanf(), printf(), strcpy, strlwr, strcmp, strlen, strcat etc.
To use these functions, you just need to include the appropriate C header files.

## **User Defined Functions**

These functions are defined by the user at the time of writing the program.
```

### **Parts of Function**

#### 1. Function Prototype

#### 2. Function Definition

#### 3. Calling a function in C

### 1. Function Prototype

**Syntax:**

dataType functionName \(Parameter List\)

**Example:**

```text
int addition();
```

### 2. Function Definition

**Syntax:**

```text
returnType functionName(Function arguments){
//body of the function
}
####Example:
int addition()
{

}
```

### 3. Calling a function in C

**Program to illustrate the Addition of Two Numbers using User Defined Function**

**Example**

```text
#include<stdio.h>
/* function declaration */int addition();
int main()
{
/* local variable definition */ int answer;

/* calling a function to get addition value */ answer = addition();

printf("The addition of the two numbers is: %d\n",answer);
return 0;
}

/* function returning the addition of two numbers */int addition()
{
/* local variable definition */ int num1 = 10, num2 = 5;
return num1+num2;

}
```

### Program Output:

```text
The addition of the two numbers is: 15
```

Loading