You Are Reading

0

C++ Lecture: 17

Unknown Sunday 5 August 2012 ,
Lecture 17
Conditional Statements (Decision Making)
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  int age1, age2;
  age1 = 12;
  age2 = 10;
  if (age1 > age2)
      cout <<"Student 1 is older than student 2";
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  int age1, age2;
  cout<<"Please enter Ali age : ";
  cin>>age1;
  cout<<"Please enter Shahid age : ";
  cin>>age2;
  if (age1 > age2)
      cout <<"Ali is older than Shahid";
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10

0 comments:

Post a Comment

 
Copyright 2010 Learn Dev C++