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

شارك معنا في حصر جميع الافكار في لغه C++ ( للمبتدئين )

بدأه MsssK في 8 أبريل 2012 · 5 رد · 7,091 مشاهدة · في لغة C و ++C
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمه الله وبركاته ..

في هالموضوع راح نحاول جمع جميع الافكار والبرامج المحتمل عملها في لغه C++

في البدايه راح يكون للمبتدئين :happy:

وبإذنت الله راح نتطور مع بعض :)

في كل اسبوع راح يطرح موضوع ( ادخال - اخراج - loop - if )

:cool: وراح نجمع جميع البرامج اللي تخص الموضوع ..

المطلوب منك : بعد قراءه الموضوع اضافه اي برنامج او فكره جديده مره عليك :blink:

الفائده من الموضوع : توسيع القدرات في حل اكبر عدد من البرامج والافكار . :wink:

بسم الله

راح نبدا بشرح مبسط فقط

( الشروحات كثيره ) الهدف تطبيقي :sad:

محتويات البرنامج : بشكل عام :wacko:

1- comments ( تستخدم لاضافه تعليق المبرمج )

2- preprocessor directive (جمله التوجيه )

3- main (الداله الرئسيه

اليوم راح ندرس : عامل الاخراج : (نص - رقم - مسأله )

ندرسه من خلال برنامج :

#include<iostream>  
using namespace std;  
int main() 
{ 
  cout << " welcome" ;
  return 0; 
}

#include<iostream>

جمله التوجيه

using namespace std;

تستخدم لعدم تكرار std في البرنامج

int main()

الداله الرئسيه

{ 
  cout << " welcome" ;
  return 0; 
}

البريكيز }{ lمهم بدايه ونهايه الداله

return0 معناه البرنامج انتهى بنجاح

cout << " welcome" ;

عامل الاخراج cout

>> عامل التوجيه للخروج على الشاشه

ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ

راح نحتاج تتابعات الخروج :

post-133999-1193400343.jpg

البرامـــــــج :

1 - برنامج لاخراج "++ welcom to c" في سطرين

2 - برنامج لاخراج "++ welcom to c" بين كل كلمه وكلمه 5 سبيس

3 -برنامج يطبع اسمك ومدينتك والدوله .

4- برنامج يطبع مسج في اربع اسطر .

يتبع الحل :)

3 -

تم تعديل هذه المشاركة بواسطة MsssK في 8 أبريل 2012 في 15:20

1
#2

1 - برنامج لاخراج "++ welcom to c" في سطرين

#include<iostream>  
using namespace std;  
int main() 
{ 
  cout << " welcome \n to C++ " ;
  return 0; 
}

2 - برنامج لاخراج "++ welcom to c" بين كل كلمه وكلمه 5 سبيس

#include<iostream>  
using namespace std;  
int main() 
{ 
  cout << " welcome \t to\t C++\t " ;
  return 0; 
}

3 -برنامج يطبع اسمك ومدينتك والدوله .

#include<iostream>  
using namespace std;  
int main() 
{ 
  cout << " name \n city \n cont  " ;
  return 0;

4- برنامج يطبع مسج في اربع اسطر .

#include<iostream>  
using namespace std;  
int main() 
{ 
	cout << " A1 \n A2 \n A3 \n A4 " ;
  return 0; 
}

طبعا البرامج هذي سهله وفكرتها وحد

المواضيع الجايه تصادفنا برامج :wacko: :wacko: :wacko: :wacko:

المايك معكم :)

#3

الموضوع الثاني :

عامل الادخال cin

ملاحضات مهمه :

لادخال اي متغير لابد من تعريفه من قبل اما متغير او ثابت

لابد من معرفه :

تعريف المتغيرات والثوابت .

شروط تسميه المتغير .

انواع المتغيرات . وطريقه التحويل فيما بينها .

تعريف المتغير على اساس محلي او عالمي وطريقه التعامل معه .

معرفه الاولويات في العمليات الحسابيه .

الاسئله :

Discuss the meaning of each of the following objects:

a) cin

ANS: This object refers to the standard input device that is normally connected to the keyboard.

b) cout

ANS: This object refers to the standard output device that is normally connected to the computer screen.

c) cerr

ANS: This object refers to the standard error device that is normally connected to the computer screen.

Fill in the blanks in each of the following:

a) are used to document a program and improve its readability.

ANS: comments

b) The object used to print information on the screen is .

ANS: cout

c) A C++ statement that makes a decision is .

ANS: if

d) Calculations are normally performed by statements.

ANS: assignment

e) The object inputs values from the keyboard.

ANS: cin

Write a single C++ statement or line that accomplishes each of the following:

a) Print the message "Enter two numbers".

ANS: cout << "Enter two numbers";

b) Assign the product of variables b and c to variable a.

ANS: a = b * c;

c) State that a program performs a sample payroll calculation (i.e., use text that helps to document a program).

ANS: // Sample Payroll Calculation Program

d) Input three integer values from the keyboard and into integer variables a, b and c.

ANS: cin >> a >> b >> c;

State which of the following are true and which are false. If false, explain your answers.

a) C++ operators are evaluated from left to right.

ANS: False. Some operators are evaluated from left to right, while other operators are evaluated right to left.

b) The following are all valid variable names: _under_bar_, m928134, t5, j7, her_sales,

his_account_total, a, b, c, z, z2.

ANS: True. All variables begin with an underscore or letter.

c) The statement cout << "a = 5;"; is a typical example of an assignment statement.

ANS: False. The statement is an output statement. a = 5; is output to the screen.

d) A valid C++ arithmetic expression with no parentheses is evaluated from left to right.

ANS: False. Arithmetic operators can appear in any order in an expression. Since multiplication, division, and modulus

have higher precendence than addition and subtraction the statement cannot be true.

e) The following are all invalid variable names: 3g, 87, 67h2, h22, 2h.

ANS: False. h22 is a valid variable name.

Fill in the blanks in each of the following:

a) What arithmetic operations are on the same level of precedence as multiplication? .

ANS: division and modulus.

b) When parentheses are nested, which set of parentheses is evaluated first in an arithmetic expression? .

ANS: innermost.

c) A location in the computer's memory that may contain different values at various times throughout the execution of a

program is called a .

ANS: variable.

What, if anything, prints when each of the following C++ statements is performed? If nothing prints, then answer “nothing.”

Assume x = 2 and y = 3.

a) cout << x;

ANS: 2

b) cout << x + x;

ANS: 4

c) cout << "x=";

ANS: x=

d) cout << "x = " << x;

ANS: x = 2

e) cout << x + y << " = " << y + x;

ANS: 5 = 5

f) z = x + y;

ANS: nothing.

g) cin >> x >> y;

ANS: 23.

h) // cout << "x + y = " << x + y;

ANS: nothing.

i) cout << "\n";

ANS: A newline is output which positions the cursor at the beginning of the next line on the screen.

Which of the following C++ statements contain variables whose values are replaced?

a) cin >> b >> c >> d >> e >> f;

b) p = i + j + k + 7;

c) cout << "variables whose values are destroyed";

d) cout << "a = 5";

ANS: Parts (a) and (b).

Given the algebraic equation y = ax3 + 7, which of the following, if any, are correct C++ statements for this equation?

a) y = a * x * x * x + 7;

b) y = a * x * x * ( x + 7 );

c) y = ( a * x ) * x * ( x + 7 );

d) y = (a * x) * x * x + 7;

e) y = a * ( x * x * x ) + 7;

f) y = a * x * ( x * x + 7 );

ANS: Parts (a), (d) and (e).

State the order of evaluation of the operators in each of the following C++ statements and show the value of x after each

statement is performed.

a) x = 7 + 3 * 6 / 2 - 1;

ANS: *, /, +, -, =, 15

b) x = 2 % 2 + 2 * 2 - 2 / 2;

ANS: %, *, /, +, -, =, 3

c) x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) ) );

ANS: *, /, +, *, *, 324

#4

البرامج :

1-

Write a complete C++ program that reads the user age and prints it again؟

The output

how old are you ? ____

you old are you ______

2-

Write a complete C++ program that ask a user to type three integers then read them into three variables first, second, and third. Finally, print them in the reverse order third, second, and first.

3-

Write a complete C++ program that reads a number then print the number before and after.?

يطلب من المستخدم رقم ويطلع الرقم اللي قبله واللي بعده ...

4-

Write a program that asks the user to enter two numbers, obtains the two numbers from the user and prints the sum, product,

difference, and quotient of the two numbers.

يطلب من المستخدم رقمين بعدين يوجد جمعهم - ضربهم - طرحهم -قسمتهم

5-

Write a program that prints the numbers 1 to 4 on the same line with each pair of adjacent numbers separated by one space.

Write the program using the following methods:

a) Using one output statement with one stream insertion operator.

b) Using one output statement with four stream insertion operators.

c) Using four output statements.

برنامج يطبع الرقام من 1الى 4

بثلاث طرق (في جمل الاخراج داخل الكود )

#5

هذا الكود يطلب من المستخدم عدد ثم يظهر مربعه (بافتراض أن زر النقطة الفاصلة معطل ! :D ) :

بالسي++ :

#include<iostream> 
void main( int x )                
{ 
    if(std::cout<<"Enter a Number:\t") {}
    if(std::cin>>x) {}
    if(std::cout<<"The result = "<<x*x) {}
}

بالسي :

#include <stdio.h>
main (int x)
{
if( printf("x = "),scanf("%d",&x),printf("carré de x = %d",x*x) ) {}
}

للمزيد : في كل يوم فائدة !

#6

^^^^

ليش استخدمت ال if

:) :)

6-

Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number

followed by the words "is larger." If the numbers are equal, print the message “These numbers are equal.”

7-

Write a program that inputs three integers from the keyboard and prints the sum, average, product, smallest and largest of

these numbers. The screen dialogue should appear as follows

8-

Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference and area. Use the constant

value 3.14159 for p. Do these calculations in output statements. (Note: In this chapter, we have discussed only integer constants

and variables. In Chapter 3 we will discuss floating-point numbers, i.e., values that can have decimal points.)

9-

What does the following code print?

cout << "*\n**\n***\n****\n*****\n";

10-

Write a program that reads in five integers and determines and prints the largest and the smallest integers in the group. Use

only the programming techniques you learned in this chapter.

11-

Write a program that reads an integer and determines and prints whether it is odd or even. (Hint: Use the modulus operator.

An even number is a multiple of two. Any multiple of two leaves a remainder of zero when divided by 2.)

12-

Write a program that reads in two integers and determines and prints if the first is a multiple of the second. (Hint: Use the

modulus operator.)

13 -

Write a program that inputs a five-digit number, separates the number into its individual digits and prints the digits separated

from one another by three spaces each. (Hint: Use the integer division and modulus operators.) For example, if the user types

in 42339 the program should print

14-

write a program that calculates the squares and cubes of the numbers

from 0 to 10

:huh: :blink: :mellow:

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…