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

دوال هامه جدا في لغه ال ++c

مغلق
بدأه fatahalrhman في 24 ديسمبر 2002 · 4 رد · 1,522 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

(1) داله لحساب الوقت time :-

time()

Prototype: time_t time(time_t* timer);

Header File: time.h

ANSI: C and C++

Explanation: Returns and sets the passed in variable to the number of seconds that have passed since 00:00:00 GMT January 1, 1970. If NULL is passed in, it will work as if it accepted nothing and return the same value.

Example:

//Program will use time_t to store number of seconds since 00:00:00 GMT Jan.

//1, 1970

#include

#include

int main()

{

time_t hold_time;

hold_time=time(NULL);

cout<<"The number of elapsed seconds since Jan. 1, 1970 is "<

return 0;

}

(2) داله لحساب القيمه المطلقه abs :-

abs()

Prototype: int abs(int aNum);

Header File: math.h and stdlib.h

Explanation: The abs function returns the absolute value of a number (makes it positive).

Example:

//Program asks for user input of an integer

//It will convert it to positive if it was negative

#include

#include

int main()

{

int aNum;

cout<<"Enter a positive or negative integer";

cin>>aNum;

cout<

return 0;

}

(3) داله لحساب جيب الزاويه ( ) sin :-

asin()

Prototype: double asin(double a_sin);

Header File: math.h

Explanation: Asin is used to find the arcsine of a number (give it a sin value and it will return the angle, in radians corresponding to that value). It must be passed an argument between -1 and 1.

//Example gives the angle corresponding to sine 1

#include

#include

int main()

{

cout<

return 0;

}

(4) داله لحساب جيب تمام الزاويه ( ) cos :-

acos()

Prototype: double acos(double a_cos);

Header File: math.h

Explanation: Acos is used to find the arccosine of a number (give it a cosine value and it will return the angle, in radians corresponding to that value). It must be passed an argument between -1 and 1.

//Example gives the angle corresponding to cosine .5

#include

#include

int main()

{

cout<

return 0;

}

(5) داله لحساب ظل الزاويه ( ) tan :-

atan()

Prototype: double atan(double a_tan);

Header File: math.h

Explanation: Acos is used to find the arctangent of a number (give it a tangent value and it will return the angle, in radians corresponding to that value). It accepts all real numbers.

//Example gives the angle corresponding to tangent 10

#include

#include

int main()

{

cout<

return 0;

}

(6) داله لحساب اللوغريثم بالنسبه للعدد ( )log :-

log()

Prototype: double log(double anumber);

Header File: math.h

Explanation: Log returns the natural logarithm for anumber, as long as it is not negative, or zero. .

//Example gives the natural logarithm of 100

#include

#include

int main()

{

cout<

return 0;

}

(7) داله لحساب الجذر التربيعي بالنسبه للعدد ( )sqrt :-

sqrt()

Prototype: double sqrt(double Value);

Header File: math.h

Explanation: Returns the square root of Value. Probably not a good idea to try a negative number for Value...

Example:

//Example will give sqare root of numbers 1 to 10

#include

#include

int main()

{

for(int x=1; x<11; x++)

cout<<"Square root of: "<

return 0;

}

(8) داله تخبرك بالساعه الان ( ) colck :-

clock()

Prototype: clock_t clock(void);

Header File: time.h

Explanation: This function returns the number of clock ticks (the CPU time taken) the program has taken. To convert to the number of seconds, divide by CLOCKS_PER_SEC, which is defined in time.h

Example:

//Example will run a loop, and then print the number of clock ticks and

//number of seconds used

#include

#include

int main()

{

for(int x=0; x<1000; x++)

cout<

cout<<"Clock ticks: "<

return 0;

}

(9) داله للقسمه ( ) div :-

div()

Prototype: div_t div(int numerator, int denominator);

Header File: stdlib.h

Explanation: Div takes a fraction (numerator/denominator) and places the quotient andthe remainder into the struct it returns, div_t. In div_t the two ints are quot and rem, quotient and remainder.

Example:

//Example shows division

#include

#include

int main()

{

div_t answer;

answer = div(76, 5)

cout<<"As an improper fraction, 76/5";

cout<<"As a proper fraction, "<

return 0;

}

(10) داله تعطي العدد مرفوع للقوة ( ) power :-

pow()

Prototype: double pow(double b, double p);

Header File: math.h

Explanation: This function raises b to the p power.

Example:

//Example will computer 4 to the 5th

#include

#include

int main()

{

cout<<"4 to the 5th power is: "<

return 0;

}

واخر دعوانا ان الحمد لله رب العالمين وصلي اللهم وبارك علي سيدنا محمد

وعلي اله عدد كمال الله وكما يليق بكماله ...........................................

مع تحياتي فتح الرحمن البحر....................................................

#2

دوووووووال حسابية رائعة مشكووووووور ;)

تحياتي (f)

#3

بعد السلام

:'( انا يا جماعه ضايع في ال(arrays) و (pointers) فاذا ممكن تساعدوني

ودلوني على موقع في ملخصات عن هذه المواضيع.........وشكرا

benakram@hotmail.com

#4

إلى الأمام يا fatahalrhman مواضيعك جيدة

#5

السلام عليكم

مجهود جيد الأخ/ fatahalrhman ، ولكن هل يمكنك وضع الأكود فى مربع الكود كى تظهر بشكل جيد .!

" وما توفيقى إلا بالله عليه توكلت وإليه أنيب "
-------------------------------------------------
قل : " لا حول ولا قوة إلا بالله "
-------------------------------------------------

هذا الموضوع مغلق.

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