الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ممكن تكملة هذا الكود

بدأه ANGLE-6 في 2 يونيو 2009 · 1 رد · 329 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه ،،

لو سمحتم احد يصحح لي هذا الكوود

ويكمل لي الكود الناقص

لاني توقفت عند نقطة لا اعرفها

وشاكره لكم تعاونكم :D

1.Write a function void createArithmeticSeq(int [], int); that prompts the user to input two numbers, first and diff. the function hen creates a one-dimensional array of n elements ordered in an arithmetic sequence. For example, if n = 16, first = 21 and diff = 5, the arithmetic sequence is:

21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96

2.Write a function that takes an array and its size as parameters, the function should print the content of the array, the prototype of the function is void print(int [], int);

3.Write a program that defines an intger array , then calls the previously mentioned two functions.

 # include <iostream>
using namespace std;
void createArithmeticSeq(int array[],int size);
{

int array[];
cout <<"enter two num "<<endl;
int first,diff;
cin>>first;
cin>>diff;
array[0]=first;

int index ;
for ( index=1;index<size;index++)
array[index]=array[index-1] + diff;

}

تم تعديل هذه المشاركة بواسطة ANGLE-6 في 2 يونيو 2009 في 20:32

#2

السلام عليكم

الداله صحيحه ولكن كان بها بعض الأخطاء

والداله الناقصه هى دالة العرض print

#include <iostream>
using namespace std;
void createArithmeticSeq(int array[],int size)
{
cout <<"enter two num "<<endl;
int first,diff;
cin>>first;
cin>>diff;
array[0]=first;

int index;
for ( index=1;index<size;index++)
array[index]=array[index-1] + diff;
}
void print(int array[],int size)
{
	for(int i=0;i<size;i++)
		cout<<array<<" ";
	cout<<endl;
}
int main()
{
	int arr[100];
	createArithmeticSeq(arr,16);
	print(arr,16);
	return 0;
}

المصفوفه arr هى فقط وعاء للقيم ولن استخدمها كلها

فى الداله main استخدمنا 16 مكان فقط فى المصفوفه

يمكن استخدام المؤشرات فى البرنامج

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

مواضيع مشابهة