Skip to content

Commit

Permalink
Merge pull request #26 from balaji303/Deci2Roman
Browse files Browse the repository at this point in the history
Come give me somethin' I can feel, oh-oh, oh
  • Loading branch information
balaji303 authored Nov 19, 2024
2 parents 3c06f3e + 550e94e commit 76c7203
Show file tree
Hide file tree
Showing 12 changed files with 1,337 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
*.ppx
*.tag
*.obj
*.lib
*.lib
/sandBox
42 changes: 42 additions & 0 deletions Module_Learning/LogitechInterviewQuestions/arrayPrint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <stdio.h>
void printArray(uint8_t *arrayVar);
int main()
{
uint8_t arr1[]={1,-2,-4,55,3,4,9,-2,5};
printArray(&arr1);

return 0;
}

void printArray(uint8_t *arrayVar)
{
for(int i=0;i<37;i=i+4)
{
if(*(arrayVar+i) > *(arrayVar+i+4))
{
print("%d",*arrayVar);
}
}
}

// This is the program I wrote for print array. The question had pass array to function

#include <stdio.h>
#include <stdint.h>

void printArray(uint8_t *arrayVar);

int main() {
int8_t arr1[] = {1, -2, -4, 55, 3, 4, 9, -2, 5};
printArray(arr1); // Pass array name directly

return 0;
}

void printArray(int8_t *arrayVar) {
for (int i = 0; i < 8 - 1; i++) { // Loop over array elements, excluding the last one
if (*(arrayVar + i) > *(arrayVar + i + 1)) {
printf("%d ", *(arrayVar + i)); // Print the current element
}
}
}
54 changes: 54 additions & 0 deletions Module_Learning/LogitechInterviewQuestions/decimalToBinary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <stdio.h>
void decimalToBinary(int *refArgu);
int main()
{
int decimalNumeber = 5;
decimalToBinary(&decimalNumeber);

return 0;
}

void decimalToBinary(int *refArgu)
{
if(*refArgu == 1)
{
printf("1");
}
else if(*refArgu % 4 == 0)
{
printf("1");
// int ver = *refArgu % 2;
// decimalToBinary(&ver);
}
else if(*refArgu % 2 == 1)
{
printf("1");
int ver = *refArgu % 2;
decimalToBinary(&ver);
}
else
{
printf("0");
}
}

//The above is the program I wrote for decimal to binary conversion. Below is the correct one

#include <stdio.h>

void decimalToBinary(int *refArgu);

int main() {
int decimalNumber = 5;
decimalToBinary(&decimalNumber);
return 0;
}

void decimalToBinary(int *refArgu) {
if (*refArgu == 0) {
return;
} else {
decimalToBinary((*refArgu) / 2); // Divide the number by 2 for next iteration
printf("%d", *refArgu % 2); // Print the remainder (0 or 1)
}
}
9 changes: 9 additions & 0 deletions Module_Learning/LogitechInterviewQuestions/limit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdint.h>
int main(void)
{
char ver = 128;
//What is the output of this
printf("%d",ver);
return 0;
}
7 changes: 7 additions & 0 deletions Module_Learning/LogitechInterviewQuestions/sample.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>

int main (void)
{
printf("Hello world Balaji");
return 0;
}
1,124 changes: 1,124 additions & 0 deletions Module_Learning/LogitechInterviewQuestions/sample.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: DecimaltoRoman","url":"e:\\GitHub\\C-Exercise\\QandA_Learning\\5_Control_Statements\\DecimaltoRoman.c","tests":[{"id":1688091181188,"input":"25","output":"XXV"},{"id":1688091185112,"input":"7","output":"VII"},{"id":1688091191448,"input":"1","output":"I"},{"id":1688091198894,"input":"100","output":"C"},{"id":1688091303148,"input":"125","output":"CXXV"},{"id":1688349982746,"input":"100","output":"C"},{"id":1688349986257,"input":"1000","output":"M"},{"id":1688436437680,"input":"2020","output":"MMXX"},{"id":1688436637034,"input":"485","output":"CDLXXXV"},{"id":1688436663294,"input":"190","output":"CXC"},{"id":1688436707977,"input":"9","output":"ix"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"e:\\GitHub\\C-Exercise\\QandA_Learning\\5_Control_Statements\\DecimaltoRoman.c","group":"local","local":true}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"Local: LinearSearch","url":"e:\\GitHub\\C-Exercise\\QandA_Learning\\7_Array\\LinearSearch.c","tests":[{"id":1687208462847,"input":"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n2","output":"1"},{"id":1687208485206,"input":"1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n99","output":"Value not found!"},{"id":1687208502591,"input":"0\n11\n22\n33\n44\n55\n66\n77\n88\n99\n99","output":"9"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"e:\\GitHub\\C-Exercise\\QandA_Learning\\7_Array\\LinearSearch.c","group":"local","local":true}
1 change: 1 addition & 0 deletions QandA_Learning/7_Array/tempCodeRunnerFile.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
valueToSearchFor
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# C Excersie and code
[![LastCommit](https://img.shields.io/github/last-commit/balaji303/C-Exercise.svg?style=social)](https://github.com/balaji303/C-Exercise/commits/master)

## Docs
- [Quick Ref](https://github.com/Fechin/reference/blob/main/source/_posts/c.md)



## Projects
- [Digit Frequency](https://github.com/balaji303/Wolverine/blob/master/test.c)
- [Adding the diagonal elements of the Matrix](https://github.com/balaji303/C-Exercise/blob/master/MatrixDiagonalAdd.c)
- [Matrix Identical or not](https://github.com/balaji303/C-Exercise/blob/master/MAtrixIdenticalorNot.c)
Expand Down
Binary file added docs/barr_c_coding_standard_2018.pdf
Binary file not shown.
93 changes: 93 additions & 0 deletions draft.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

itle: Unleashing the Potential of Embedded Systems

Introduction

Embedded systems have evolved significantly, becoming indispensable in industries such as automotive, aerospace, and healthcare. This article delves into the vital role of embedded systems in today's world and the future advancements we can expect.

1. The Evolution of Embedded Systems

Embedded systems have transformed from simple microcontroller-based devices to complex systems, incorporating powerful processors, vast memory, and diverse operating systems. This evolution has expanded their capabilities, allowing them to tackle more complex tasks and communicate seamlessly.

2. IoT and Embedded Systems

The Internet of Things (IoT) is a driving force behind the growth of embedded systems. IoT devices are built on embedded systems, enabling efficient data processing and transmission. The expanding IoT landscape will increase demand for powerful, energy-efficient, and secure embedded systems, providing opportunities for innovation.

3. Embedded Systems in Automotive Applications

Embedded systems play a crucial role in modern automotive design, from engine control modules to advanced driver assistance systems. As manufacturers strive for higher fuel efficiency, reduced emissions, and improved safety, the role of embedded systems will continue to grow, especially in autonomous vehicles.

4. AI and Machine Learning

Artificial intelligence (AI) and machine learning (ML) are transforming embedded systems, enabling them to learn and adapt to changing environments. Embedded systems with AI and ML capabilities can analyze vast amounts of data, make intelligent decisions, and improve system performance.

5. The Future of Embedded Systems

Future trends in embedded systems include:

a. Energy Efficiency: Embedded systems will prioritize energy efficiency, utilizing techniques like dynamic voltage scaling and low-power design.

b. Security: Advanced encryption, secure boot, and hardware-based security features will be integrated into future embedded systems.

c. Edge Computing: The demand for real-time data processing will drive the growth of edge computing, where embedded systems process data locally.

d. 5G and Beyond: The advent of 5G and subsequent wireless technology generations will enable embedded systems to communicate faster and more reliably.

Conclusion

Embedded systems' role in various industries will grow exponentially. By embracing the future of embedded systems, businesses can unlock their potential and create innovative solutions that improve lives and shape the world.


--------------
When a C program is compiled, it is divided into several sections, including the .text, .data, and .bss segments. The .bss (Block Started by Symbol) segment is a portion of memory that is reserved for uninitialized global and static variables.

The .bss segment is typically located after the .data segment in memory and before the heap. It is set aside during the compilation process and initialized to zero before the program starts running. The size of the .bss segment is determined at compile time based on the number of uninitialized global and static variables declared in the program.

Uninitialized global and static variables are those that are not explicitly initialized with a value in the code. For example, if you declare a global or static integer variable but don't assign a value to it, it will be placed in the .bss segment.

One important thing to note is that since the .bss segment is initialized to zero, there is no need to store any actual data in the executable file. Instead, the linker just reserves a block of memory of the appropriate size for the uninitialized variables.

In summary, the .bss segment is a portion of memory reserved for uninitialized global and static variables in a C program. It is set aside during compilation, initialized to zero at runtime, and located after the .data segment in memory. Understanding the different memory segments of a C program is crucial for developing efficient and stable software. Happy coding!
--------------
When a C program is compiled and executed, its memory is divided into different segments. Understanding these segments and their overlaps is crucial for efficient programming and avoiding memory-related issues. In this post, we will discuss the four main segments of a C program's memory and their overlaps.

1. Text segment:
The text segment, also known as the code segment, is where the compiled code of the program resides. This segment is read-only and contains the program's instructions, including all the functions, statements, and declarations. The text segment is usually located at the lowest memory address and is not shared with other programs.

2. Data segment:
The data segment is where initialized global and static variables are stored. This segment is writable, and it contains data that is accessed and modified during the program's execution. The data segment is usually located after the text segment and before the heap and stack segments.

3. Heap segment:
The heap segment is used for dynamic memory allocation. When a program needs to allocate memory during runtime, it requests it from the heap segment. This segment is also writable and grows dynamically as more memory is allocated. The heap segment is located above the data segment and can overlap with the stack segment.

4. Stack segment:
The stack segment is used for storing function call frames and local variables. This segment grows and shrinks dynamically as functions are called and return. The stack segment is usually located at the top of the memory address space and grows downwards. The stack segment can overlap with the heap segment if they grow towards each other.

In summary, a C program's memory is divided into text, data, heap, and stack segments. These segments overlap in some cases, and understanding their interaction is crucial for efficient programming and avoiding memory-related issues. By managing these segments effectively, programmers can ensure their programs run smoothly and efficiently.


-------------------------
If you are a beginner embedded engineer and you want to start a more in-dept knowledge adventure, you don't need to much.

You can start with simple questions. Example :
Why do we need cross compilation in order to compile another machine which is not your PC?
Cross-compilation is the process of compiling code on one machine (known as the host machine) to run on another machine (known as the target machine) with a different architecture or operating system.

Embedded systems are computer systems designed to perform a specific task, such as controlling machinery or monitoring sensors. Unlike general-purpose computers, embedded systems often have limited resources, such as processing power, memory, and storage. They also may have different architectures and operating systems than the development machine.
When developing software for embedded systems, it is often necessary to compile the code on a different machine than the target device.

This is because the development machine typically has a different architecture and operating system than the target device.
For example, let's say you are developing software for an embedded device that runs on an ARM processor. Your development machine, however, runs on an x86 processor.
The code you write on your development machine needs to be compiled to run on the ARM processor.

If you try to compile the code directly on your development machine, it will not work because the compiler is designed for x86 architecture, not ARM.

Cross-compilation solves this problem by allowing you to compile code on the development machine that is compatible with the target device's architecture and operating system.
You can use a cross-compiler, which is a special type of compiler that generates code for a different architecture or operating system than the one it is running on.

When you cross-compile, you generate machine code that is compatible with the target device's architecture and operating system.

This machine code can then be loaded onto the target device and executed without any further modifications.

Want more details on that? Simple, ask a 'why' in each paragraph and try to answer it. That's how I learn things. You should try as well.

0 comments on commit 76c7203

Please sign in to comment.