C++

Add to Favourites
Post to:

Description
Learn C++ in this content.


Type: ppt

Discussion
Presentation Transcript Presentation Transcript

C++ program : C++ program 1.Programming- the basics

PowerPoint Presentation : A simple C++ program - main.cpp #include using namespace std; int main( ) { cout<< “Every age has a language of its own”; return 0; } Functions Functions are one of the fundamental building blocks of C++ . The Main.cpp program consists almost entirely of a single function called main( ).

PowerPoint Presentation : Function name The parantheses following the word main are the distinguishing feature of a function. We’ll see that the parantheses aren’t always empty. They’re used to hold function arguments: values passed from the calling program to the function. Braces and the Function Body The body of a function is surrounded by braces. They surround a block of program

PowerPoint Presentation : statements . In this example, there are only two statements in the function body: the line starting with cout, and the line starting with return. However, a function body consist of many statements. Let us see another C++ program //prime.cpp #include using namespace std; #include

PowerPoint Presentation : int main( ) { unsigned long n,j; cout<< “Enter a number: ”; cin>>n; for (j=2; j<=n/2; j++) if(n%j==0) { cout<<“ It’s not prime; divisible by “<< j <

PowerPoint Presentation : cout<<“It’s prime\n ”; return 0; } Output Enter a number: 13 It’s prime Enter a number:22229 It’s prime Enter a number: 22231 It’s not prime; divisible by 11

1 Follower

Your Facebook Friends on WizIQ