Sep 27, 2011

A set of simple programs written by C + + programming language

1-multiplier (using the idea of ​​recursion):

#include <iostream.h>
#include <conio.h>
int fact (int);
void main ()
{
int y;
cout << "Enter number: ";
cin >> y;
cout << "fact= " << fact(y);
getch();
}
int fact (int y)
{
if (y>1)
y = y * fact(y-1);
else
y=1;
return y;
}





2 - multiplier (without recursion):


#include <iostream.h>
#include <conio.h>
void main ()
{
int c,n,f=1;
cout << "Enter number: ";
cin >> n;
if (n>0)
{for (c=1; c<=n; c++)
f=f*c;
cout << "fact= " << f;}
else if (n == 0)
cout << "factorial=1";
else
cout << "the number < 0 !! try again";
getch();
}







3 - multiplication table for any number we choose:

#include <iostream.h>
#include <conio.h>
void main ()
{
int i,b;
cout << "Enter number: ";
cin >> b;
for (i=0; i<=10; i++)
cout << "\n" << b * i;
getch ();
}







4 - This program is to examine student grades if successful or not:


#include <iostream.h>
#include <conio.h>
void main ()
{
int a,b;
cout << "Enter your mark: ";
cin >> a;
cout << "Enter the lowest mark: ";
cin >> b;
if (a>b)
cout << "pass";
else
cout << "not pass";
getch ();
}





5 - function call does not return values ​​and do not pass the transaction:


#include <iostream.h>
#include <conio.h>
void starline( );
void main( )
{
starline( );
cout << " Safa2 Jaidi\n";
starline( );
cout << " from Qalqilia " << endl;
cout << " Palestine " << endl;
starline( );
getch ();
}
void starline( )
{
for ( int j = 0; j < 17 ; j++)
cout << '*' ;
cout << endl ;
}



Sep 25, 2011

Printed figures of 1-10 without the use of a camel spin (using the idea of ​​recursion):


#include <iostream.h>
#include <conio.h>int num (int);void main (){int i=1;cout << num (i);getch ();}int num (int i){if (i<10)cout << num (i+1)<< "\n";return i;}



Sep 24, 2011

A set of simple programs written in C + + programming language

1-This program will analyze the number of primary factors:


#include <iostream.h>
#include <conio.h>
void main ()
{
int j, n;
char ch;
do
{
cout << "Enter a numbers: ";
cin >> n;
for (j = 2 ; j <= n/2; j++)
if ( n % j == 0 )
cout << n << " divisible by: " << j << endl ;
cout << "again (y/n)?";
cin >> ch;
}
while (ch != n);
getch ();
}








2-Largest number among three numbers (the shortcut method):


#include <iostream.h>
#include <conio.h>
void main ()
{
float a , b , c , max ;
char ch;
do
{
cout << "\nEnter three numbers: \n" ;
cin >> a >> b >> c;
max = (a > b ) ? ((a > c) ? a:c ): ((b > c) ? b:c );
cout << max << " is the grater.\n" ;
cout << "\nagain (y/n)?";
cin >> ch;
}
while (ch != 'n');
getch ();
}








3-The way the program calculates the shortcut monthly net salary after tax it according toconditions:
2% will be deducted from the salary that is less than or equal to 1000
3% will be deducted from the salary that between the 1000 and the 2000:

#include <iostream.h>
#include <conio.h>
void main ()
{
float S, N;
L: cout << "\nEnter your salary: " ;
cin >> S;
N =(S <= 1000) ? S-S*.02:((S>=2000) ? S-S*.04 : S-S*.03);
cout << "Net salary after tax is: " << N << endl;
goto L;
getch ();
}








Sep 23, 2011

A set of video clips from YouTube wish to take advantage of them is a group lessons to learn the programming language C + +A set of video clips from YouTube wish to take advantage of them is a group lessons to learn the programming language C + +

Let's Learn C++: Lesson 0: Code::Blocks





Let's Learn C++: Lesson 1: Structure








Let's Learn C++: Lesson 2: Variables and Data Types







Let's Learn C++: Lesson 3: Input and Output





Let's Learn C++: Lesson 4: Operators and Math





Let's Learn C++: Lesson 5: If Statements





Let's Learn C++: Lesson 6: While, For, and Do While Loops





Let's Learn C++: Lesson 7: Jump Statements






Let's Learn C++: Lesson 8: Functions - Part 1





Let's Learn C++: Lesson 8: Functions - Part 2



Let's Learn C++: Lesson 9: Strings and Arrays - Part 1





Let's Learn C++: Lesson 9: Strings and Arrays - Part 2







Let's Learn C++: Lesson 10: Pointers




Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Premium Wordpress Themes