Skip to content

Commit

Permalink
journal sem-1 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TejasBhovad committed Dec 12, 2022
1 parent 2eab510 commit 28704ae
Show file tree
Hide file tree
Showing 49 changed files with 517 additions and 9 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Structured programming Journal programs

All C programs relevant to Semester I
All C programs relevant to Semester I Journal

## Table of Contents

Expand All @@ -15,7 +15,12 @@ All C programs relevant to Semester I
5. [ Pascal triangle](/pascalsTriangle/explaination.md)
6. [Sine series](/sineSeries/explaination.md)
7. [Matrix operations](/matrices/explaination.md)
<br>
8. [String Operations](/stringManipulation/explaination.md)
9. [Fibonacci Series](fibonacci/explaination.md)
10. [Search](search/explaination.md)
11. [Employee Structure](employee/explaination.md)
12. [Swap Numbers](swap/explaination.md)
<br>

### How to Compile

Expand Down
5 changes: 4 additions & 1 deletion armstrongNumber/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ int main()

## Output

![Output](/src/output/armstrong.png)
![Output](/src/output/3-o_p.png)

## Code
![Code](../src/output/3-code.png)

<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
Expand Down
66 changes: 66 additions & 0 deletions employee/explaination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!-- Use CTRL+K+V if you are in VS code -->

## Question [11]

WAP to accept EMPLOYEE details Name. Designation, Gender. DOJ and Salary)\
Define function members to compute\
i)total number of employees\
ii)total number of employees with salaries greater than 20k

## Code

```c
#include <stdio.h>
struct employee
{
char name[30];
char designation[30];
char gender[10];
int doj;
float salary;
};

int main()
{
struct employee emp[10];
int n, empCount = 0, highSalCount = 0;
printf("\nEnter the number of employees: ");
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
printf("\nEMPLOYEE %d:- ", i + 1);
printf("\nEnter the name of employee: ");
scanf(" %[^\n]s", emp[i].name);
printf("Enter the Designation of employee: ");
scanf(" %[^\n]s", emp[i].designation);
printf("Enter the gender of employee: ");
scanf(" %[^\n]s", emp[i].gender);
printf("Enter the Date of joining of employee: ");
scanf("%d", &emp[i].doj);
printf("Enter the Salary of employee: ");
scanf("%f", &emp[i].salary);
empCount++;
if (emp[i].salary > 20000)
{
highSalCount++;
}
}
printf("\nTotal No of Employees: %d", empCount);
printf("\nTotal No of Employees with Salary greater than 20k: %d", highSalCount);
printf("\n");
}
```

## Output

![Output](/src/output/11-o_p.png)

## Code

![Code](../src/output/11-code.png)

<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Sublime Text - https://www.sublimetext.com/download
--!>
39 changes: 39 additions & 0 deletions employee/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <stdio.h>
struct employee
{
char name[30];
char designation[30];
char gender[10];
int doj;
float salary;
};

int main()
{
struct employee emp[10];
int n, empCount = 0, highSalCount = 0;
printf("\nEnter the number of employees: ");
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
printf("\nEMPLOYEE %d:- ", i + 1);
printf("\nEnter the name of employee: ");
scanf(" %[^\n]s", emp[i].name);
printf("Enter the Designation of employee: ");
scanf(" %[^\n]s", emp[i].designation);
printf("Enter the gender of employee: ");
scanf(" %[^\n]s", emp[i].gender);
printf("Enter the Date of joining of employee: ");
scanf("%d", &emp[i].doj);
printf("Enter the Salary of employee: ");
scanf("%f", &emp[i].salary);
empCount++;
if (emp[i].salary > 20000)
{
highSalCount++;
}
}
printf("\nTotal No of Employees: %d", empCount);
printf("\nTotal No of Employees with Salary greater than 20k: %d", highSalCount);
printf("\n");
}
41 changes: 41 additions & 0 deletions fibonacci/explaination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- Use CTRL+K+V if you are in VS code -->

## Question [9]

WAP to display Fibonacci Series using Recursion

## Code

```c
#include <stdio.h>
int fibonacci(int n)
{
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main()
{
int n, a = 0, b = 1, tmp;
printf("Enter N: ");
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
printf("%d ", fibonacci(i));
}
printf("\n");
return 0;
}
```
## Output
![Output](/src/output/9-o_p.png)
## Code
![Code](../src/output/9-code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Sublime Text - https://www.sublimetext.com/download
--!>
19 changes: 19 additions & 0 deletions fibonacci/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
int fibonacci(int n)
{
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main()
{
int n, a = 0, b = 1, tmp;
printf("Enter N: ");
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
printf("%d ", fibonacci(i));
}
printf("\n");
return 0;
}
5 changes: 4 additions & 1 deletion grades/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ int main()

## Output

![Output](/src/output/grades.png)
![Output](/src/output/2-o_p.png)


## Code
![Code](../src/output/2-code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Expand Down
4 changes: 3 additions & 1 deletion matrices/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ int main()

## Output

![Output](/src/output/matrix.png)
![Output](/src/output/7-o_p.png)

## Code
![Code](../src/output/7-code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Expand Down
6 changes: 5 additions & 1 deletion pascalsTriangle/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ int main()

## Output

![Output](/src/output/pyramid.png)
![Output](/src/output/5-o_p.png)

## Code

![Code](../src/output/5-code.png)

<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
Expand Down
4 changes: 3 additions & 1 deletion powerOperations/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ int main()

## Output

![Output](/src/output/power.png)
![Output](/src/output/4-o_p.png)

## Code
![Code](../src/output/4_code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Expand Down
4 changes: 3 additions & 1 deletion salary/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ int main(){

## Output

![Output](/src/output/salary.png)
![Output](/src/output/1-o_p.png)

## Code
![Code](../src/output/1-code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Expand Down
58 changes: 58 additions & 0 deletions search/explaination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!-- Use CTRL+K+V if you are in VS code -->

## Question [10]

WAP to search for an Element in an Array using functions

## Code

```c
#include <stdio.h>
int search(int ar[], int n, int key)
{
for (int i = 0; i < n; i++)
{
if (ar[i] == key)
{
return 1;
break;
}
}
return 0;
}
int main()
{
int ar[20], key, n;
printf("\nEnter Size of Array: ");
scanf("%d", &n);
printf("\nEnter Elements of Array: \n");
for (int i = 0; i < n; i++)
{
scanf("%d", &ar[i]);
}
printf("\nEnter Element to be searched: ");
scanf("%d", &key);
if (search(ar, n, key))
{
printf("\nElement found in Array\n");
}
else
{
printf("\nElement not found in Array\n");
}
}
```
## Output
![Output](/src/output/10-o_p.png)
## Code
![Code](../src/output/10-code.png)
<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
VS Code - https://code.visualstudio.com/download
Sublime Text - https://www.sublimetext.com/download
--!>
34 changes: 34 additions & 0 deletions search/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
int search(int ar[], int n, int key)
{
for (int i = 0; i < n; i++)
{
if (ar[i] == key)
{
return 1;
break;
}
}
return 0;
}
int main()
{
int ar[20], key, n;
printf("\nEnter Size of Array: ");
scanf("%d", &n);
printf("\nEnter Elements of Array: \n");
for (int i = 0; i < n; i++)
{
scanf("%d", &ar[i]);
}
printf("\nEnter Element to be searched: ");
scanf("%d", &key);
if (search(ar, n, key))
{
printf("\nElement found in Array\n");
}
else
{
printf("\nElement not found in Array\n");
}
}
6 changes: 5 additions & 1 deletion sineSeries/explaination.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ int main()

## Output

![Output](/src/output/sine.png)
![Output](/src/output/6-o_p.png)

## Code

![Code](../src/output/6-code.png)

<!--
Note: if you are using text-editor to view this document I highly recommend you to use vs code or sublime text so its easier to read the contents of the file
Expand Down
Binary file added src/output/1-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/1-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/10-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/10-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/11-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/11-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/12-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/12-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/2-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/2-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/3-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/3-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/4-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/4_code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/5-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/5-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/6-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/6-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/7-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/7-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/8-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/8-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/9-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/output/9-o_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/output/armstrong.png
Binary file not shown.
Binary file removed src/output/grades.png
Diff not rendered.
Binary file removed src/output/matrix.png
Diff not rendered.
Binary file removed src/output/power.png
Diff not rendered.
Binary file removed src/output/pyramid.png
Diff not rendered.
Binary file removed src/output/salary.png
Diff not rendered.
Binary file removed src/output/sine.png
Diff not rendered.
Loading

0 comments on commit 28704ae

Please sign in to comment.