# 2.3 Pointers and arrays  (Page 7/8)

 Page 7 / 8
int a[100];int i, n; int max;printf("\n Enter the size of the array: "); scanf("%d",&n); // Read the number of elements of the arrayfor(i = 0; i<n; i++) {printf("\n a[%d] = ",i);scanf("%d",&a[i]);} // Find the maximum elementmax = a[0]; // max is initialized by a[0]// compare max to other elements for(i = 1; i<n; i++) if(max<a[i]) //meet an element greater than maxmax = a[i]; // replace max by the new value from the elements.printf("\n The maximum element of the array is: %d", max);

## Searching

The simplest type of searching process is the sequential search. In the sequential search, each element of the array is compared to the key, in the order it appears in the array, until the first element matching the key is found. If you are looking for an element that is near the front of the array, the sequential search will find it quickly. The more data that must be searched, the longer it will take to find the data that matches the key using this process.

here is the sample session with the above program

#include<stdio.h>#include<conio.h>void main() {int m[100], idx[100]; int n; // n is the actual size of the arrayint i, k, test; clrscr(); // clear screen// Read array m // Read the actual size of mprintf(“ Enter the number of elements scanf(“%d”,&n); // Read array’s elementsfor(i = 0;i<n;i++) {int temp; printf(“\n Enter the value of m[%d]= “,i); scanf(“%d”,&temp); m[i]= temp; }// Read the searching key k printf(“\n Enter the value you want to search : “);scanf(“%d”,&k); // Begin searchingtest = 0; // Scan all the elementsfor(i = 0;i<n;i++) if(m[i]= = k)//Compare the current element with the //searching key k{ // save the index of the current element idx[test]= i; test ++;} // Conclusionif(test>0) {printf(“\n there are %d elements which has the value of %d”,test,k); printf(“\n Indexes of those elements: “);for(i = 0;i<test;i++) printf(“%3d”,idx[i]); }else printf(“\n No element has the value %d”,k);getch(); // Wait until the user press any key }

## Sorting

Selection sort is a sorting algorithm, specifically an in-place comparison sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations. It works as follows:

• Find the minimum value in the list
• Swap it with the value in the first position
• Repeat the steps above for remainder of the list (starting at the second position)

Effectively, we divide the list into two parts: the sublist of items already sorted, which we build up from left to right and is found at the beginning, and the sublist of items remaining to be sorted, occupying the remainder of the array.

Here is an example of this sort algorithm sorting five elements:

31 25 12 22 11 11 25 12 22 3111 12 25 22 31 11 12 22 25 31 #include<stdio.h>#include<conio.h>void main() {int m[100];//100 is the maximum size for array mint n; // n is the number of elements int i, j, k; clrscr(); // clear screen// Read the elements of array m // Read the actual size of the arrayprintf(“ Enter the number of elements: “); scanf(“%d”,&n); // Read array elementsfor(i = 0;i<n;i++) {int temp; printf(“\n Enter the value of m[%d]= “,i); scanf(“%d”,&temp); m[i]= temp; }// Print the array printf(“\n The array before sorting: “);for(i=0;i<n;i++) printf(“%3d”,m[i]); // Begin to sortfor(i = 0; i<n-1;i++) {// Put the minimum value in the list of n-i elements //to the ith positionfor(j = i+1;j<n;j++) {// compare m[i] with other element of the sublist// and swap m[i] and m[j]if m[j]<m[i].if(m[j]<m[i]){ int temp;temp = m[j]; m[j]= m[i]; m[i]= temp; }} // Print the array after the i+1 th step of sorting processprintf(“\n The array after step %d”,i+1); for(k = 0;k<n ;k++) printf(“%3d”,m[k]); }getch(); // Wait until the user press any key. }

what's a psy.d degree
Psychology Doctorate. The main difference between PsyD and PhD Psychology is that PsyD mainly focuses on clinical sessions and PhD focuses on research.
Shrajan
so most of the phd holders become professors teaching what they have learnt
Bridget
Hi, I have a question. What factors influence social facilitation and social inhibition in groups?
it really depends on that person on how the can task in life either they can work better with other people or you do worse working with people.
Lametra
Lametra
Lametra
Do you know of any studies done to show social facilitation and social inhibition
Amritpal
social facilitation is often influenced by the person's perception of the situation and their appraisal of the task. for example, a track athlete who views their competition as a challenge rather than a threat, will tend to run the fastest they have ever ran under a large crowd.
Another condition is if the person has mastered the ability to perform that task. A track athlete who trains everyday, will perform above average under a large crowd, however, someone who does not run, will tend to do worse than their actual ability under a large crowd
social inhibition can be explained through evolutionary biology or attachment personality theory. some people develop an avoidance personality trait, which when they feel under pressure, they tend to leave the group or avoid a gathering due to high lev of stress
Does anyone know how I can transfer my higher national diploma credits in usa?
Oh wow. I never realised there was a chat on this app!
Then welcome dearest
Bridget
Thank you! ❤️
Amritpal
thank you
Ana
Hello Ana, good afternoon from here
hello im new student here.
Rai
hello
Rai
I m also student.
Rai
hi
Kavya
what is easier option to psychology?
Dhanaraj
I'm new too
Deniz
As in the the specialisation or ?
Bridget
good morning
Ana
understanding human nature is what we are going to talk about.
Ana
Philip
“ Every child is left to evaluate his experiences for himself, and to take care of his own personal development outside the classroom. There is no tradition for the acquisition of a true knowledge of the human psyche. The science of human nature thus finds itself today in the position that chemis
Ana
well, I think every individual is different and to a great extent we can't say confidently that we understand the human nature in its entirety
Philip
lack determines what we will become in life?.
Ana
Not 100% but it plays a huge role
Philip
Hi! I wasn't aware there was a chat feature on this app 😊
Ophelia
👍Philip Anyaegbu
Ana
cool
Ana
👍
Ana
yes Ana I'm here
Philip
alternatively we are different, we have basic similar qualities
Bridget
Yes true Bridget.
Philip
hello there
Ciel
Hi
Philip
hi
Ej
hi
KUNDAN
hi
Ana
who we are how we think what we do insight
Ana
@ bridget. yes that's true
Ana
Ana ioanidis? do you speak Greek?
Qwanta
Qwanta no I dont speak Greek my husband does
Ana
are you a psychologist? or your husband?
Qwanta
I need some reliable informations about my studies...
Qwanta
not a psychologist
Ana
Ana
so what is the cause why a person experiences a psychological disorder if it not of their own?
it's partly genetics,culture, environment and substance abuse. generally these are the common factors which can lead to most of the disorders
war
waoo
Rai
r u proficcer
Rai
u r psychology subject
Rai
not a professor but a clinical psychologist
war
can i ask you, i keep getting headache, and had a history of hypothyroid ans diagnosed as having mild anxiety disorder. i want to finish. my undergraduate psychology thesis.. but always unable to have good ambition and energy to focus on writing the case and the theories... whats the best remedy
Astaroxche
Ana
297 according to the DSM 5
how many disorders are there
interesting question
Mahmoud
it is😅
Nelly
I'm guessing it's in the tens of thousands, maybe hundreds if you include counter interactions and stuff like it. although I'm sure it's almost impossible to know for sure, unless you're very rich and connected to the right people. but as I said: guessing.
Beenie
There are more than 200 classified forms of mental illness. Some of the more common disorders are: clinical depression, bipolar disorder, dementia, schizophrenia and anxiety disorders. Symptoms may include changes in mood, personality, personal habits and/or social withdrawal. that is what I think
Mahmoud
too difficult to number. diagnosing a disorder is just checking off boxes on a compilation of symptoms that might match any particular condition on the DSM
what is psychology of the guest
I don't understand the question can you elaborate?
Edgar
the study of philosophy gives to the sociologist
why women are viewed as far more emotional than men?
because they actually are ,I guess.
Collins
May be they are biologically milder than man. It does not mean they are not equal with man. Man can also be emotional and can are oppressed with traditional norms. For example, man are not to be cry, in actual man are also emotional being and they cannot have the right to show their sentiment.
shine
sollungal bro sollungal...
Balaji
because of she has hormonal fluctuations than men..
bavi
usually women are more emotional than men and they are multi talented people
lavanya
Both men and women are capable of expressing emotions. But women has the highest percentage of doing that. Because our society is conditioned by nature in such a way that men are expected to suppress their emotions and motivate them through their acts or thoughts, which has it's side effects of....
Santos
denial of any emotion which they feel that useless at that point. Women in the other hand were encouraged/not controlled to suppress their emotions and let them out what they feel about it. I feel that's the wonderful superpower of the women.
Santos
y
Mahmoud
Men's emotion comes mostly with memories triggered by senses. That means, they thoughts have the power to decide whether to let go of emotions or not.
Santos
Q
Mark
because women tend to be more agreeable than men.
Edgar
women at a young age are conditioned to be more in tune with emotion than man should be less
David
The question is "Why women Viewed are as far more emotional than men ?" it's not a question whether women are more emotional than men. This is more an issue about the point of view from the observer, his/her assumption what emotional behavior is or what emotional behavior is.
Mehmet
The anwers are answers more to the question " Are women more emotional than men?"
Mehmet
hi are you on what'sap
no not really a fan of social laziness
Robert
huh
Parmizan
is there any way for a Btech E.C.E. graduate to take on MSC. PSYCHOLOGY
devesh
ya you can just by cracking entrance , if in India
Mansi
Any stream in UG can go for M.Sc (Psychology)
classification of traits and how they are measured
what was Freud's first name?
Sigmund
Dentriodite
sigmund
Margie
Sigismund Schlomo Freud
Sigmund Freud
Talal
sigmund
Ankita
Leon Vygotsky and Sergei Rubenstein please tell me contributions of these personalities in in 4 lines
Uzma
sigmund Freud
Harpreet
Lev Vygotsky was the founder of socio-cultural theory
Jo
So psychology was based off of the Greek gods I that right or no?
psychology is the study. anything -ology is the study of a certain field. Psyche is a mortal woman who becomes divine in Greek mythology. The etymology of the word "psyche" in Greek means "spirit" or "soul"
Got questions? Join the online conversation and get instant answers!