This Program performs the WHILE conditional statement with user function and IF…ELSE conditional statement
#include <iostream.h>
int warning = -1;
int get_status(void)
{
return warning;
}
int main()
{
int count = 10;
while (count-- > 1)
{
if (get_status() == warning)
break;
cout << '\n' << count;
}
if (count == 0)
cout << "Shuttle launched\n";
else
{
cout << "\nWarning received\n";
cout << "Count down held at t - " << count;
}
return 0;
}
This is an interactive C++ program using IF…ELSE conditional statement
#include <iostream.h>
main()
{
char name[16];
int age;
cout << "Enter your name: ";
cin >> name;
cout << "Enter your age: ";
cin >> age;
if (age < 21)
cout << "You young whippersnapper, " << name << "!\n";
else if (age < 40)
cout << name << ", you're still in your prime!\n";
else if (age < 60)
cout << "You're over the hill, " << name << "!\n";
else if (age < 80)
cout << "I bow to your wisdom, " << name << "!\n";
else
cout << "Are you really " << age << ", " << name << "?\n";
return 0;
}
This Program performs simple WHILE and IF conditional statements
#include <iostream.h>
int main()
{
int num = 0;
while (num++ <= 10)
{
if (num % 2 != 0)
continue;
cout << '\n' << num;
}
return 0;
}
This Program performs how to use STRCPY() and STRCAT() functions inside the main() module
#include <iostream.h>
#include <string.h>
int main()
{
char name[60];
strcpy(name, "Bilbo ");
strcat(name, "Baggins");
cout << name;
return 0;
}
#include <iostream.h>
int warning = -1;
int get_status(void)
{
return warning;
}
int main()
{
int count = 10;
while (count-- > 1)
{
if (get_status() == warning)
break;
cout << '\n' << count;
}
if (count == 0)
cout << "Shuttle launched\n";
else
{
cout << "\nWarning received\n";
cout << "Count down held at t - " << count;
}
return 0;
}
This is an interactive C++ program using IF…ELSE conditional statement
#include <iostream.h>
main()
{
char name[16];
int age;
cout << "Enter your name: ";
cin >> name;
cout << "Enter your age: ";
cin >> age;
if (age < 21)
cout << "You young whippersnapper, " << name << "!\n";
else if (age < 40)
cout << name << ", you're still in your prime!\n";
else if (age < 60)
cout << "You're over the hill, " << name << "!\n";
else if (age < 80)
cout << "I bow to your wisdom, " << name << "!\n";
else
cout << "Are you really " << age << ", " << name << "?\n";
return 0;
}
This Program performs simple WHILE and IF conditional statements
#include <iostream.h>
int main()
{
int num = 0;
while (num++ <= 10)
{
if (num % 2 != 0)
continue;
cout << '\n' << num;
}
return 0;
}
This Program performs how to use STRCPY() and STRCAT() functions inside the main() module
#include <iostream.h>
#include <string.h>
int main()
{
char name[60];
strcpy(name, "Bilbo ");
strcat(name, "Baggins");
cout << name;
return 0;
}
No comments:
Post a Comment