Some C Programming Language Tips - Doc (Repaired)
Some C Programming Language Tips - Doc (Repaired)
Some C Programming Language Tips - Doc (Repaired)
Language Tips:
(1)
#define TEST //The Green colored section want be compiled except this line is
been written
Program(){
……………………………
………………………………
…………………………..
#ifdef TEST
……………………………..
……………………………..
………………………………
#end if
……………………………..
……………………………..
(2)
…………………………
…………………………………………
……………………………………………
#if 0
………………………………..
………………………………..
………………………………...
#end if
(3)
……………………………
……………………………
…………………………...}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Famous Question of SySDSoft:
(1) How can processes communicate?
Answer:
Process A
Process A
Shared Memory
Process B
Kernel Process B
(2) What is the difference between Hard Real Time and Soft Real Time?
i. Keypad input
ii. Message visualization
iii. System status representation
(3) What is Meant by Function Reentrancy?
(4) What is the difference between Real Time Systems and Normal
Systems?
Real Time Systems needs for deterministic timing behavior. We ento seed el
3arfeen ya3ni we 7ate3rafo tegawboh be kafa2a isa.
Cache Memory reduces Predictability, It’s not used in Hard Real Time
Systems “walahy ma3raf leih we yareit elli ye3raf ye2ool”.
Reason: real-time system must have predictable performance so that
hardware resources can be effectively scheduled, ensuring that all deadlines
are met. Cache memories, by their nature, have unpredictable access times
Process and Preemption Process is the single task of the software that
can be handled separately that represents the background behavious of the
software “zai el task tamam zai ma2al 3amr 3adel lamma negi netakllem
3annaha in general we el preemption ento seed el 3arfeen”
Floating Point
Although when both are compiled, no memory reservation takes place unless
a variable of this time is been declared, Union’s fields affect each others
while structure doesn’t.
i.e. Unions reserve a memory space of the largest variable type that is
contained by it, this memory space is been used by all variables “once a
time.
Example:
Union mytype{
Int A;
Char B;
Char Name[50];
}
Stack : The is no direct access to the stack elements “ lazem a3mel pop le
element wara el tani le7ad mawsal lelli ana 3awzoh”; It’s size is not
predetermined “ya3ni kol ma3ooz a3mel push a3mel 3adi we mosh
mo7addad be length mo3ayan (tab3an mosh asdi 3ala el stack allocation elli
2al 3aleih Eng. Tamer)”
Array : The is direct access to the array elements “ sahl awy 2a2ol arr[5] aw
arr[8]”; It’s size is predetermined “ya3ni hena wana ba3mel decalaration lel
array lazem 2akoon me7aded el length leha 7atta law mastakhdemtesh kol el
amaken di”
(9) What is the difference between the array and the linked list?
//the main idea of macros is that, it’s a preprocessing and that we don’t
have //to determine the type of neither x nor y.
(11) How can you sort an array entered by a user without any element
repetition ? “ yagama3a dah el 7al beta3i, we 3aref walahi enni 7al
mo3awak :D :D :D we en ento masha2 allah 7ate3rafo te3melolo
optimization a7san men keda beketeer”
#include <stdio.h>
#include <conio.h>
void bbl_Sort(int * ptr)
{
int flag=1;
int temp,i;
while(flag)
{
flag=0;
for(i=9;i>=1;i--)
if(ptr[i]<ptr[i-1])
{
temp=ptr[i];
ptr[i]=ptr[i-1];
ptr[i-1]=temp;
flag++;
}
}
}
Int no_Rep (int * ptr)
{
int ptr_array_index=0;
int temp[10],i;
for(i=0;i<=9;i++)
temp[i]=ptr[i];
ptr[ptr_array_index]=temp[0];
ptr_array_index++;
for(i=1;i<=9;i++)
if(temp[i]==temp[i-1])
continue;
else
{ptr[ptr_array_index]=temp[i]; ptr_array_index++;}
return (ptr_array_index-1);
}
(12) How can yoy manage accessing a certain element in a linked list?
“yagama3a dah el linked list kolaha we 7atla2o westaha ezai a3mel
accessing for a certain element, Please find the attached .cpp file named
Linked List”
Stack:
Static memory allocation is all the time since it’s a RAM or ROM variables while
dynamic memory allocation is Heap or stack; i.e. has a life time.
(16) What is the difference between Pointers and dynamic allocation?
“Eng. Ahmed Loutfy’s Answer”
Pointer is a data type itself that is used to refer to what it points to, or the address
it contains; the pointer itself is a static allocation when it’s declared before
compiling “in the code”
The dynamic allocation is used to reserve a piece of memory during the runtime
and return only the first address “reference” of this piece as a pointer to void …so
we need a pointer and a casting process to save this reference to be able to deal
with this piece of memory.