HelloWord for Parallel Computing
/*
============================================================================
Name : ads.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello MPI World in C
============================================================================
*/
#include
#include
#include "mpi.h"
int main(int argc, char* argv[]){
int my_rank; /* rank of process */
int p; /* number of processes */
int source; /* rank of sender */
int dest; /* rank of receiver */
int tag=0; /* tag for messages */
char message[100]; /* storage for message */
MPI_Status status ; /* return status for receive */
/* start up MPI */
MPI_Init(&argc, &argv);
/* find out process rank */
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
/* find out number of processes */
MPI_Comm_size(MPI_COMM_WORLD, &p);
if (my_rank !=0){
/* create message */
sprintf(message, "Hello MPI World from process %d!", my_rank);
dest = 0;
/* use strlen+1 so that '\0' get transmitted */
MPI_Send(message, strlen(message)+1, MPI_CHAR,
dest, tag, MPI_COMM_WORLD);
}
else{
printf("Hello MPI World From process 0: Num processes: %d\n",p);
for (source = 1; source < p; source++) {
MPI_Recv(message, 100, MPI_CHAR, source, tag,
MPI_COMM_WORLD, &status);
printf("%s\n",message);
}
}
/* shut down MPI */
MPI_Finalize();
return 0;
}
bu hazır geliyor Open MPI ile :) şuan labdayım yah
Software Engineering.
Categories
- vb (10)
- visual basic (10)
- Glassfish (9)
- java (8)
- Software engineering (5)
- pardus (4)
- C++ (3)
- Canım İstedi (3)
- OpenSolaris (3)
- jdk (3)
- Database (2)
- Mim (2)
- BackTrack (1)
- Basit Dos Komutları (1)
- Binary Tree Traversals (1)
- Dim (1)
- Hakkımda (1)
- Java öğren (1)
- Larry Ellison (1)
- Msn (1)
- Pardus geliştircileri toplantısı (1)
- Programlama Dilleri (1)
- Ramazan Bayramı (1)
- Steve Jobs (1)
- Streaming (1)
- VritualBox (1)
- Windows (1)
- film (1)
- merkez bankası (1)
- parallel Computing (1)
- virüs (1)
- xml (1)
- yazılım mühendisliği (1)
Links
/*
============================================================================
Name : lab.c
Author :
Version :
Copyright : Your copyright notice
Description : Array in elemanlarını toplayan C kodu
============================================================================
*/
#include
#include
#include "mpi/mpi.h"
int main(int argc, char* argv[]){
int my_rank; /* rank of process */
int p; /* number of processes */
int i;
int allsum =0;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &p);
int vector[10];
int arr[500];
int arrr[500];
int as = 500 / p;
if (my_rank == 0){
for (i = 0; i < 500; i++)
arr[i] = i;
}
MPI_Scatter(arr, as, MPI_INTEGER, arrr, as, MPI_INTEGER, 0, MPI_COMM_WORLD);
int sum = 0;
for (i = 0; i < as; i++)
sum += arrr[i];
printf("Myrank: %d, sum: %d\n", my_rank, sum);
MPI_Reduce(&sum, &allsum, 1, MPI_INTEGER, MPI_SUM, 0, MPI_COMM_WORLD);
//MPI_Gather(&sum, 1, MPI_INTEGER, vector, 1, MPI_INTEGER, 0, MPI_COMM_WORLD);
if (my_rank == 0)
{
printf("%d ", allsum);
}
MPI_Finalize();
return 0;
}
Etiketler: parallel Computing
Öğrenci seçme ve yerleştirme sınavı yapıldı. Sonrasında tercihler yapıldı. kimse bir yerlere yerleşemedi. Sırada ne var ek yerleştirmeler. Bugün bana gelen bir maille bölümüm hakkında Yani Yazılım Mühendisliği hakkında bir yazı yazmam gerektiğin ve benden sonra bu bölümü seçecekler için az da olsa bu yazının yol gösterici olması gerektiğini anladım.
Yazılım mühendisliği bölümünün daha önce yapılmış bir çok tanımı var genel anlamda “Yazılım Mühendisliği 1968 yılında NATO tarafından gerçekleştirilen bir konferans esnasında ortaya çıkan yeni bir kavram ve yeni bir mühendislik alanı olup, yazılım sistemlerinin mühendislik prensipleri çerçevesinde tasarımı, üretimi ve işletilmesini hedeflemektedir. Bilgisayar sistemleri artık günlük hayatın her alanında yoğun ve etkin bir şekilde kullanılmakta olduğundan, Yazılım Mühendisliği tüm disiplinlerde uygulamaları olan bir alan.
- Kullanıcı ihtiyaçlarını analiz ederek, uygun çözümlere tasarlayabilmek,
- Kullanıcının belirlediği fakat genelde sürtüşmelere yol açan zaman, maliyet, kullanılabilirlik noktalarında uzlaşma sağlayabilmek,
- Mühendislik yaklaşımlarını kullanırken etik, sosyal, yasal ve ekonomik ilgileri bütünleştirecek uygun çözümler tasarlamak.
- Yazılım tasarımı, geliştirilmesi, gerçekleştirimi ve doğrulanması için bir temel sağlayan mevcut teorileri, modelleri ve teknikleri anlamak ve uygulayabilmek.
- Yazılım geliştirme ortamında etkin olarak çalışmak, gerekli olduğunda liderlik yapabilmek ve kullanıcılarla iyi iletişim kurabilmek bir diğer deyişle proje yönetimi becerisi.
- İlgili alanlardaki gelişmeleri takip edip, uygulayabilmek” yazının tamamı için (http://www.csharpnedir.com/articles/read/?id=230)
Yazılım mühendisliği bilgisayar mühendisliğine nazar daha az donanım derslerine sahip ortak olarak alınan programlama derslerini yanı sıra daha çok bir yazılım mühendisliği müşterinin istediği veya ihtiyaç doğrultusunda en iyi şekilde nasıl yapılabilir? nasıl yönetilebilir? gibi dersleri içermektedir. 4 yıl boyunca bir yazılım mühendisliği bölümünden alınacak yazılım dersleri programı
1) SE 112 - Yazılım Mühendisliğine Giriş
2) İnsan Bilgisayar Etkileşimi
3) Yazılım Kalite Güvencesi
4) Sistem Yazılımının Sınanması ve Onaylanması
5) Yazılım Gereksinimleri Mühendisliği
6) Yazılım Tasarımı ve Mimarisi
7) Nesneye Dayalı Analiz ve Tasarım
8) Yazılım Proje Yönetimi
9) Sistem Modelleme ve Simülasyon
10) Büyük Ölçekli Sistem Yazılımı Geliştirme (www.atilim.edu.tr)
Gibidir. Bu derslerin konusu ve içeriği IEEE(http://ieeesb.gantep.edu.tr/intro.htm) tarafından hazırlanmaktadır.
İş imkanına gelince Yazılım mühendisliği bölümü Türkiye de çok yeni bir bölüm ve bu sene ilk mezunlarını verdi. Gün geçtikçe değerlenen bir bölümdür. Ama ne yazık ki Türkiye de ve genel anlamda oluşan krizden dolayı bilişim sektöründe de bir durgunluk söz konusu. Eleman sıkıntısı çok fazla ama iş yapan firma sayısı çok az. İş yapabilecek firma sayısı çok az. Birde bazı gerçekler var. Bugün firmalar 10 kuruşa bir iş yaptırmak yerine bu işin sertifikasını almış yada 2 yıllık bir programdan mezun olmuş elamana 3 kuruş verip ona yaptırmayı daha doğru buluyor. Buda mezunların iş bulma şansını birazda olsa aşağı çekiyor. Bir alanda uzmanda değil de her şeyden anlayan eleman çalıştırmaya daha az para vermeye çalışıyorlar. Bir başka gerçek bu gün büyük ölçekli yazılım firmalarında yine bir Türkiye gerçeği olan “torpil ”olayı çok fazla. Eğer size yardımcı olacak bir dayınız yoksa bu firmalar da çalışma imkanınız yok denecek kadar az. Bu durumda okul biter bitmez kurslara devam ediyor olabilirsiniz network, database veya yazılım alanında bir sertifika programına kaydolarak alacağınız bu belgelere den biriyle birazda olsa iş bulma şansınızı artırabilirsiniz. Sormak istedikleriniz için bana mail atabilirsiniz. Son olarak aşağıda Atılım Üniversitesi Yazılım Mühendisliği Bölümü Başkanı Sayın Ali YAZICI nın CNN Türk’e yapmış olduğu söyleşi var izlemenizi kesinlikle tavsiye ederim.
Herkese Kolay gelsin.
Mesut ALTINYAPRAK
2010.05.25 CNN Türk BaÅ�arıya DoÄ�ru Prof.Dr. Ali Yazıcı
Yükleyen atilim_universitesi. - Partiler, yurt hayatı ve diÄ�er üniversite videoları.
Etiketler: Software engineering, yazılım mühendisliği
Nesne yönelimli Programlama (Object-Oriented Programming) Tekniği ve C++
Bugün pek çok yüksek seviyeli programlama dilleri bu tekniği desteklemektedir. O yüzden bu yaz elimden geldiğince ana başlıklar dan yola çıkarak C++ nedir nedeğildir iyice ararşıtırırken öğrendiklerimide sizinle paylaşmak istedim. Şimdi genel özellikleriyle C++ diyelim ve başlayalım.
1- c++'ta Local değişkenlerin bildirimleri blokların başında yapılmak zorunda değildir. Yani
{} aç kapa yaptıktan sonra nerde isterseniz değişkenleri tanımlayabilirsiniz.
2- c++'ta Local değişkenin faaliyet alanı bildirim noktasından blok sonuna kadar olan bölgeyi kapsar. Ne olursa olsun bir blok içersinde aynı isimli birden fazla değişken bildirimi yapılamaz.
3- for döngüsünün birinci kısmında bildirim yapılabilir. Ve etkinliği for döngüsün içinde bulunduğu bloğun sonuna kadar etkilidir.
Örn: For( int i=0; i<=length; i++)
4- while ve if döngleri içersinde tanımlama yapılamaz.
5- DEFİNATİON için küçük bir örnek.
#include
#define SIZE 100
void main () {
for (int i=0; i
return 0;
}
6- if, for, switch, while gibi deyimlerden sonra blok açılmamış olsa bile gizli bir blogun açıldığı düşünülmelidir.
7- // ile satır sonuna kadar yorum yapılabilinir.
/* */ arasında kalan herşey yorum olarak kabul eder.
8- Çağrılan fonksiyon eğer çağıran fonksiyonun yukarısında tanımlanmamışsa fonksiyon prototipi zorunludur.
9-farklı parametre yapılarına sahip aynı isimli birden fazla fonksiyon tanımlanabilir.
Örn: void mesut (int x){ }
void mesut (void) {}
burada çağrılma (call) ifadesindeki parametre sayısı ve türü hangisine uygunsa o çağrılmış olur. Geri dönüş değerinin farklı olması aynı isimli fonksiyon yazmak için yeterli değildir.
Yani, geri dönüş değerleri farklı fakat parametre yapısı aynı olan birden fazla fonksiyon tanımlanamaz.
10- C++ derleyicisi aynı sayıda parametrelere sahip birden fazla aynı isimli fonksiyonun bulunması durumunda çağrılma ifadesine tür bakımından uygun bir fonksiyon bulamazsa bu durum “Ambiguity between fonk(int) and fonk (long) bunun bir diğer ismi iki anlamlılık hatasıdır.
Örneğin: fonksiyon float parametreyle çağrılmışsa ancak float parametreye sahip bir fonksiyon yoksa double parametreye sahip bir foksiyon tanımlanmışsa bu durumda double parametreye sahip olan foksiyon çağrılır.
11- tanımlanan ve çağrılan bir fonksiyon ismi .obj modül içersine yazılmak zorundadır. Buda içiersinde aynı isimli birden çok fonksiyon modülü içersine yazılamaz demeketir.
12- Dinamik bellek yönetimi new ve delete operatörleriyle yapılır. Ve bu malloc, claloc, realloc ve free fonksiyonlarıyla yapılabilir. Ancak bu fonksiyonlar OOP yönelimliprogramlama tekniği uygulayabilmek için tasarlanmıştır.
13- C++'ta dinamik olarak tahsis edilme potansiyelindeki boş bölgelere free store denilmektedir. C dilinde ise HEAP denir.
14- NEW Operatörü:
new(TÜR) [<[UZUNLUK]>]
new int
new char
new double [100] gibi
int *p;
p= new int;
Exam:
#include
#include
{
char *p;
p =new char[100];
cin>>p;
for(int i=0; i<100; i++);
cout<}
Exa: Tam olarak ad, soyad uzunluğu kadar bellekte yer ayıran fonksiyon
#include
#include
char *getname(void)
{
char *p;
char buf[100];
printf(”Name and Surname”);
gets(buf);
p=new char [strlen(buf)+1];
if(p==NULL){
printf(“Cannot allocate memory..\n”);
return 1;
}
strcpy (p.buf)
return p;
}
void main (){
char *p;
p=getname();
puts(p);
}
15- Delete operatörü new opratörü ile memory de yar açılmış olan blokların serbest bırakılması için kullanılır 2 şekilde kullanımı vardır
delete p; tek member için
delete [] p; birden fazla member için
16- Bir adresin farklı türden bir pointer'a ve adres olmayan bir bilginin bir pointer'a atanması durumu error olarak değerlendirilir. Yani adres işlemlerinde tür uyuşmazlığı C++'ta eror olarak değerlendirilir.
Örn;
void main (){
int s[10];
chat *t;
t=s ; // dediğin anda cannot conver int to char hatası alırsın.
Ama
t=(char *)s ; // hata vermez.
17- const bir değişkenin adresi ancak const bir pointer'a atanmalıdır.
const int x;
int *y;
const int *p;
y=&x; // HATALI dır.
p=&x;// DOĞRU dur.
18- const bildirimi ile yaratılmış bir değişken sabit ifadesi gibi işlem görür. Const bir değişken için yine bellekte yer ayrılır. Const ilk değeri aldığı Ya da atandığı andan itaberen o değişkeni kullanır.
Örn: const int MAX=y+8;
const int MIN=0;
x=MAX;
x=MIN;
const int SIZE =10;
int y[SIZE];
const değişken için bellekte yer ayrılır. Bu durumda const değişkenin adresi alınabilinir.
Void main (){
const SIZE=100;
int *p;
p=(int *)&SIZE;
*p=20;
printf(“%d/n”.SIZE);
}
19- Statik ömürlü değişkenlere sabit ifadesiyle ilk değer atama zorunluluğu yoktur. C'de vermek zorundayız. Çünkü static değişkenler il değer içersine yazılır. Exe dosyası içersinde yer alırlar. Bunun mümkün olabilmesi için verilen ilk değerin derleme aşamasında belirlenmiş olması gerekir. C++'ta static değişkenlere her türden öylesine bir değer verilebilinir. Bu değişkenler 0 ilk değeriyle amaç koda yazılırlar. Programın çalışma zamanı sırasında ve main fonksiyonundan önce ilk değerlerini alırlar.
Kendi alanımla alakısız bir yazı yazacağım.Bu haftasonu finallere girmeden önce hazır sınavlarda bitmişken ee bide şenlik haftası eğlenceye kapıldık umarım bunun rehaveti daha fazla sürmez :) hafta sonunu da eğlenerek geçireyim istedim. Ankarada tanınmış bir mekana gittim normalde içki içmem bir içki söyledim dursun önümde içmicem dedim, içmedim de ama ortama da ayak uydurdum :) ben ve bir abim vardı eğleniyorduk. kıpır kıpır canlı müzik her anında tempo tutarak keyifle geçiriyorduk. Mekan sahibi tanıdık olduğu için bize çok güzel ikramlarda bulundu meyve tabakları çerezler falan ağzınız sulanmasın tadımlık doyumluk değil di :) Neyse tam o noktada olay koptu bende ben nerdeyim ne yapıyorum ? diye sordum kendime kafamı kaldırıp etrafıma baktığım anda gerçekten güzel kızlar kendilerinden geçerseni eğleniyorlardı.Büyük bir çoğu mini etekli dekolteleriyle ve yanlarında erkek arkadaşlarıyla eee saat ilerledikçe alkolün de etkisiyle işin rengi iyiden iyiye değişmeye başlıyordu. Buda beni ilgilendirmiyor. Peki ne anlatmaya çalışıyosun hayu sen diye bilirsiniz. Kızlar bir yandan erkek arkdaşlarına kur yaparken bir yandan da başkalarını kesmeye devam ediyorlardı. Evetttt doğru söylüyorum. Onda aklıma bi film geldi bilenleriniz vardır mutlaka karındeşen jack gerçek bir hikayedir. filmde katil kurbanlarını ozamanın en pahalı iki şeyi ile kandırıyordu 1.Üzüm 2. ise Şarap ve o an gördüğüm meyve tabağı ile manzara karşısında dedimki bunun filmedki rollerle arasında ki fark nedir ?acaba kızlarımız bunlara kanıptamı buraya geliyorlar ve sevmedikleri istemedikleri halde birileriyle birlikte olmaya mı çalışıyorlar? Bu nesif tabaklar için.Bi an aklıma filmediki kurbanlar dan farksız oldukları geliyordu. Nasıl diceksiniz ? jack kurbanlarını bu dünya lezetlerini tadtırdıktan sonra öldürüyordu. Peki bizim jackler ne yapıyor. Öldürmüyorlar ellerinden bişelerini alıp "bir kız arkadaşımın tabiriyle kendimi paylaşacak kadar sevdim" gönderiyorlar sarhoş olan kızlarımız neleri kaybettiklernin farkında değiller uyanmıcaklar farkına varmıcaklar asla. Ama bigün biri gelip onlara neyi kaybettiklerini hatırlatana kadar. Bunu bütün kızlar için yazdığımı sanmayın ama bu yazı bir kaç kişi içinde değil.Umarım dünya da insanlar para, zevk,lezzet için onurlarını erdemlerini ayaklar altına aldırtmazlar.
Güç,Cesaret,Erdem= ZAFER. sonuç olarak film karalerinden çok ta uzak değil yaşananlar.
Etiketler: Canım İstedi
Evet başlığındanda anlaşılacağı üzere yazımız mülakata girmek üzerine olacak ama sakın yanlış anlmayın kitaplardan anladığımı anlatmayacağım. Tamamen başıma gelenleri paylaşacağım.Bugun bir firmaya mülakata gittim çok rahattım çünkü ben daha öğrenciyim bana hayır desler bile onların neye evet dediğini öğrenip bir daha hayır cevabıyla karşılaşmamak için gerekli tedbirleri alcaktım mülakattan çıktım bu yazıyı biran önce buraya yazmalıyım bunu paylaşmalıyım diye dolmuşta içim içimi yiyip durdu sonunda odamdayı ve bilgisayalırım karşımda ve başımdan geçenler
Okulda çok yorucu bir koşuşturmacanın ardından iyice hayattan bezmiş bi şekilde ama birazda bakımlı halimle bindin gölbaşı arabasına gitti Gazi Teknopark'a evet daha öncede bu yerde stajımı yapmıştım MAKROKOD da hemen onun karşısıydı bu kez gittiğim firma bi an eski şirketle göz göze geldim kapı açılınca içerden tanıdık diye heycanlıydım her neyse. Öncesinde mülakatta ne yapılmalıdır nasıl? davranılmalıdır ? Nasıl konuşulmalıdır gibi yüzlerce sayfa tavsiyede bulunan sayfları okudum ama bir yerde hataya düştügüm şey vardı bunlar oturuşa duruşa çok önem vermiyorlar bunlar senin nasıl bir kıvrak zekaya sahip oldugunla ilgileniyorlar burda açıkcası çok bir işime yaramadı neyse kapıyı çaldım girdim heyecanlanmışcam diye şartlandırmıştım kendimi beni saolsun patron karşıladı toplantı salonuna aldı 10 dakika sonra kendisi geldi ve elinde cv im in olduğu kağıt ve artık başlıyoruz. Sanki adranalin biraz yüseldi devam ediyoruz planlarından bahsediyorlar evet çok güzel sonra bana bir soru soruyor algorithma üzerine yaparmısın yok demek ne mümkün ben bildiğim unutmuşum evet yaparım dedim ama kendime güveniyorum soruyu sor kendine çözümünde söyle ve arkasından if while for tamam hepsi bu :) soru geldi bana asalsayıları ekrana basan bir program yaz :) basit dedim bi loop yaptım 1 3 5 7 9... diye gidiyor sence bir sorun varmı var nedir ? 9 asal değil hayda kim buldu dokuzu asala sayı nedir ne değildir derken ordan bir not aldık. sonra linux who çekmek nedir dendi via dana bahsedildi c++ dosya okuma dendi 30.000 satırlık bir text dosyasını word açamıyor bunu nasıl açarımmın cevabını öğrendim BCNF açılımını unuttum ama sonrasında hatıraladıgımda ha bu çok kalay dedim evet neyse çok etkin bi yazı değil araya telefon girdi böle heycanlıydı.
Step 1: Define the problem
The first thing you need to figure out is what problem your program is attempting to solve. Ideally, you should be able to state this in a sentence or two. For example:
•I want to write a phone book application to help me keep track of my friend’s phone numbers.
•I want to write a random dungeon generator that will produce interesting looking caverns.
•I want to write a program that will take information about stocks and attempt to predict which ones I should buy.
Although this step seems obvious, it’s also highly important. The worst thing you can do is write a program that doesn’t actually do what you (or your boss) wanted!
Step 2: Define your targets
When you are an experienced programmer, there are many other steps that typically would take place at this point, including:
•Understanding who your target user is
•Defining what target architecture and/or OS your program will run on
•Determining what set of tools you will be using
•Determining whether you will write your program alone or as part of a team
•Collecting requirements (a documented list of what the program should do)
However, as a new programmer, the answers to these questions are typically simple: You are writing a program for your own use, alone, on your own system, using an IDE you purchased or downloaded. This makes things easy, so we won’t spend any time on this step.
Step 3: Make a heirarchy of tasks
In real life, we often need to perform tasks that are very complex. Trying to figure out how to do these tasks can be very challenging. In such cases, we often make use of the top down method of problem solving. That is, instead of solving a single complex task, we break that task into multiple subtasks, each of which is individually easier to solve. If those subtasks are still too difficult to solve, they can be broken down further. By continuously splitting complex tasks into simpler ones, you can eventually get to a point where each individual task is manageable, if not trivial.
Let’s take a look at an example of this. Let’s say we want to write a report on carrots. Our task hierarchy currently looks like this:
•Write report on carrots
Writing a report on carrots is a pretty big task to do in one sitting, so let’s break it into subtasks:
•Write report on carrots
◦Do research on carrots
◦Write outline
◦Fill in outline with details about carrots
That’s a more managable, as we now have three tasks that we can focus on individually. However, in this case, “Do research on carrots is somewhat vague”, so we can break it down further:
•Write report on carrots
◦Do research on carrots
■Go to library and get book on carrots
■Look for information about carrots on internet
◦Write outline
■Information about growing
■Information about processing
■Information about nutrition
◦Fill in outline with details about carrots
Now we have a hierarchy of tasks, none of them particularly hard. By completing each of these relatively manageable sub-items, we can complete the more difficult overall task of writing a report on carrots.
The other way to create a hierarchy of tasks is to do so from the bottom up. In this method, we’ll start from a list of easy tasks, and construct the hierarchy by grouping them.
As an example, many people have to go to work or school on weekdays, so let’s say we want to solve the problem of “get from bed to work”. If you were asked what tasks you did in the morning to get from bed to work, you might come up with the following list:
•Pick out clothes
•Get dressed
•Eat breakfast
•Drive to work
•Brush your teeth
•Get out of bed
•Prepare breakfast
•Get in your car
•Take a shower
Using the bottom up method, we can organize these into a hierarchy of items by looking for ways to group items with similarities together:
•Get from bed to work
◦Bedroom things
■Get out of bed
■Pick out clothes
◦Bathroom things
■Take a shower
■Brush your teeth
◦Breakfast things
■Prepare breakfast
■Eat breakfast
◦Transportation things
■Get in your car
■Drive to work
As it turns out, these task hierarchies are extremely useful in programming, because once you have a task hierarchy, you have essentially defined the structure of your overall program. The top level task (in this case, “Write a report on carrots” or “Get from bed to work”) becomes main() (because it is the main item you are trying to solve). The subitems become functions in the program.
If it turns out that one of the items (functions) is too difficult to implement, simply split that item into multiple subitems, and have that function call multiple subfunctions that implement those new tasks. Eventually you should reach a point where each function in your program is trivial to implement.
Step 4: Figure out the sequence of events
Now that your program has a structure, it’s time to determine how to link all the tasks together. The first step is to determine the sequence of events that will be performed. For example, when you get up in the morning, what order do you do the above tasks? It might look like this:
•Get out of bed
•Pick out clothes
•Take a shower
•Get dressed
•Prepare breakfast
•Eat breakfast
•Brush your teeth
•Get in your car
•Drive to work
If we were writing a calculator, we might do things in this order:
•Get first number from user
•Get mathematical operation from user
•Get second number from user
•Calculate result
•Print result
Step 5: Figure out the data inputs and outputs for each task
Once you have a hierarchy and a sequence of events, the next thing to do is figure out what input data each task needs to operate, and what data it produces (if any). If you already have the input data from a previous step, that input data will become a parameter. If you are calculating output for use by some other function, that output will generally become a return value.
When we are done, we should have prototypes for each function. In case you’ve forgotten, a function prototype is a declaration of a function that includes the function’s name, parameters, and return type, but does not implement the function.
Let’s do a couple examples. GetUserInput() is pretty straightforward. We’re going to get a number from the user and return it back to the caller. Thus, the function prototype would look like this:
view sourceprint?
1.int GetUserInput()In the calculator example, the CalculateResult() function will need to take 3 pieces of input: Two numbers and a mathematical operator. We should already have all three of these by the time we get to the point where this function is called, so these three pieces of data will be function parameters. The CalculateResult() function will calculate the result value, but it does not display the result itself. Consequently, we need to return that result as a return value so that other functions can use it.
Given that, we could write the function prototype like this:
view sourceprint?
1.int CalculateResult(int nInput1, char chOperator, int nInput2);Step 6: Write the task details
In this step, for each task, you will write it’s actual implementation. If you have broken the tasks down into small enough pieces, each task should be fairly simple and straightforward. If a given task still seems overly-complex, perhaps it needs to be broken down into subtasks that can be more easily implemented.
For example:
view sourceprint?
1.char GetMathematicalOperation()
2.{
3.
char chOperation;
4.
cin >> chOperation;
5.
// What if the user enters an invalid character?
6.
// We'll ignore this possibility for now
7.
return chOperation;
8.}Step 7: Connect the data inputs and outputs
Finally, the last step is to connect up the inputs and outputs of each task in whatever way is appropriate. For example, you might send the output of CalculateResult() into an input of PrintResult(), so it can print the calculated answer. This will often involve the use of intermediary variables to temporary store the result so it can be passed between functions. For example:
view sourceprint?
1.// nResult is a temporary value used to transfer the output of CalculateResult()
2.// into an input of PrintResult()
3.int nResult = CalculateResult(nInput1, chOperator, nInput2);
4.PrintResult(nResult);This tends to be much more readable than the alternative condensed version that doesn’t use a temporary variable:
view sourceprint?
1.PrintResult( CalculateResult(nInput1, chOperator, nInput2) );This is often the hardest step for new programmers to get the hang of.
Words of advice when writing programs
Keep your program simple to start. Often new programmers have a grand vision for all the things they want their program to do. “I want to write a role-playing game with graphics and sound and random monsters and dungeons, with a town you can visit to sell the items that you find in the dungeon” If you try to write something too complex to start, you will become overwhelmed and discouraged at your lack of progress. Instead, make your first goal as simple as possible, something that is definitely within your reach. For example, “I want to be able to display a 2d representation of the world on the screen”.
Add features over time. Once you have your simple program working and working well, then you can add features to it. For example, once you can display your 2d world, add a character who can walk around. Once you can walk around, add walls that can impede your progress. Once you have walls, build a simple town out of them. Once you have a town, add merchants. By adding each feature incrementally your program will get progressively more complex without overwhelming you in the process.
Focus on one area at a time. Don’t try to code everything at once, and don’t divide your attention across multiple tasks. Focus on one task at a time, and see it through to completion as much as is possible. It is much better to have one fully working task and five that haven’t been started yet than six partially-working tasks. If you split your attention, you are more likely to make mistakes and forget important details.
Test each piece of code as you go. New programmers will often write the entire program in one pass. Then when they compile it for the first time, the compiler reports hundreds of errors. This can not only be intimidating, if your code doesn’t work, it may be hard to figure out why. Instead, write a piece of code, and then compile and test it immediately. If it doesn’t work, you’ll know exactly where the problem is, and it will be easy to fix. Once you are sure that the code works, move to the next piece and repeat. It may take longer to finish writing your code, but when you are done the whole thing should work, and you won’t have to spend twice as long trying to figure out why it doesn’t.
Most new programmers will shortcut many of these steps and suggestions (because it seems like a lot of work and/or it’s not as much fun as writing the code). However, for any non-trivial project, following these steps will definitely save you a lot of time in the long run. A little planning up front saves a lot of debugging at the end.
The good news is that once you become comfortable with all of these concepts, they will start coming naturally to you without even thinking about it. Eventually you will get to the point where you can write entire functions without any pre-planning at all.
by
http://www.learncpp.com/cpp-tutorial/1-10a-how-to-design-your-first-programs/
Etiketler: Software engineering
error C2065: 'add' : undeclared identifier
error C2373: 'add' : redefinition; different type modifiers
gibi hatalar alırsanız bunun çözüm yolu aşağıdaki örnekte ki gibidir
#include
int add(int x, int y, int z);
int main()
{
using namespace std;
cout << "3 + 4 + 5 = " << add(3, 4, 5) << endl;
return 0;
}
int add(int x, int y, int z)
{
return x + y + z;
}
önce den bir prototype ını belirleyin porgramınız yukarıda olduğu gibi
ReturnType FunctionName (Variable Declaration); şeklinde yada
2. alternatif olarak ta main() function nın dan önce call ettiğiniz function ının defination yapın. türkçesi çok kötü oldu ya :)
Consequently, our program will compile and link correctly.IncludeHeader
You’re probably curious why we use angled brackets for iostream, and double quotes for add.h. The answer is that angled brackets are used to tell the compiler that we are including a header file that was included with the compiler. The double-quotes tell the compiler that this is a header file we are supplying, which causes it to look for that header file in the current directory containing our source code first.
Rule: Use angled brackets to include header files that come with the compiler. Use double quotes to include any other header files.
Another commonly asked question is “why doesn’t iostream have a .h extension?”. The answer is, because iostream.h is a different header file than iostream is! To explain requires a very short history lesson.
When C++ was first created, all of the files in the standard runtime library ended in .h. Life was consistent, and it was good. The original version of cout and cin lived in iostream.h. When the language was standardized by the ANSI committee, they decided to move all of the functions in the runtime library into the std namespace (which is generally a good idea). However, this presented a problem: if they moved all the functions into the std namespace, none of the old programs would work any more!
To try to get around this issue and provide backwards compatibility for older programs, a new set of header files was introduced that use the same names but lack the .h extension. These new header files have all their functionality inside the std namespace. This way, older programs that include #include
Make sure when you include a header file from the standard library that you use the non .h version if it exists. Otherwise you will be using a deprecated version of the header that is no longer supported.
As a side note, many headers in the standard library do not have a non .h version, only a .h version. For these files, it is fine to include the .h version. Many of these libraries are backwards compatible with standard C programming, and C does not support namespaces. Consequently, the functionality of these libraries will not be accessed through the std namespace. Also, when you write your own header files, they will all have a .h extension, since you will not be putting your code in the std namespace.
Rule: use the non .h version of a library if it exists, and access the functionality through the std namespace. If the non .h version does not exist, or you are creating your own headers, use the .h version
by http://www.learncpp.com/cpp-tutorial/19-header-files/
i am talk about step by step how can work backtrack
open first terminal then,
1- iwconfig
2- iwconfig wlan0 (find your driver code here for exa: wlan0)
3- iwconfig wlan0 mode monitor (follow)
4- airodump-ng -c 11 --bssid (make adress here) wlan0 -w test.cap
then, Open second terminal other terminal is still working
5- aircrack-ng test.cap
----------------------------------------o--------------------------------------------
gives make adress here
aireplay-ng -b make (ACC) -S your make adress
artık hep yanımdasın :)))
Burada jdk ayarlarının yapılışını resimli olarak çok iyi anlatmışlar yardım alabileceğiniz bir site
http://www.ktuce.com/forum/showthread.php?tid=48
How to install Flash player in OpenSolaris
1.Download the Solaris version of flash player to your machine.
2. Untar that file.
3. Open terminal.
4. #su
5. cp libflashplayer.so /usr/lib/firefox/plugins/
6. restart firefox
Posted on: Mar 20, 2009
Posted by: Abhishek Gupta
Category: Sun
Etiketler: OpenSolaris