0% found this document useful (0 votes)
10 views5 pages

Activity 17 20

The document contains summaries of 5 programs written in C++. Program 17 checks if a character entered is a number or letter. Program 18 checks if a number is even or odd. Program 19 calculates a student's grade average and output. Program 20 checks if a character is a vowel or consonant using a switch statement. The summaries identify syntax errors in some programs and provide the corrected code.

Uploaded by

heyyben21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Activity 17 20

The document contains summaries of 5 programs written in C++. Program 17 checks if a character entered is a number or letter. Program 18 checks if a number is even or odd. Program 19 calculates a student's grade average and output. Program 20 checks if a character is a vowel or consonant using a switch statement. The summaries identify syntax errors in some programs and provide the corrected code.

Uploaded by

heyyben21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name: RAVEN M.

BERCASIO
Section: BSIT M21
Subject: COMPRO1

Day 5 Activity
Program 17

#include<iostream>

using namespace std;

int main ()
{
char ch;
cout << " Enter a Character: ";
cin >> ch;

if (ch>='0' && ch<='9')


{
cout << "You entered a number!";
}

else
{
cout << "You entered a letter!";
}

return 0;
}

Program 18

#include<iostream>

using namespace std;

int main()
{
int num;
cout(("Enter the number: "<<endl;
cin))num;
if(num%2==0)
cout(("The number "<<num<<" is even.");
else
cout("The number ")num()" is odd.";

return 0;
}
Program 19

#include<iostream.h>
#include<conio.h>
main()

int name[15];
int PG,MG,FG;
float GA;
clrscr();
cout<<"Enter your name: ";
cin>>name;
cout<<"Enter Prelim Grade: ";
cin<<PG;
cout<<"Enter Midterm Grade: ";
cin>>MG;
cout<<"Enter final Grade: ";
cin>>FFG;
GA = PG*.3+MG*.3+FG*.4;
cout.precision(2);
if (GA<=75 && GA<=100)
cout<<"Congratulations "<<name<<"!!!"<<endl;
cout<<"Your grade is "<<PG<<endl;
cout<<"You passed.";
else (FG>=65 && FG<75)
{
cout<<"Bad news "<<name<<"!!!"<<endl;
cout<<"Your grade is "<<FG<<endl;
cout<<"You failed";

}
else
cout<<"Hi "<<<name<<"!!!"<<endl;
cout<<"Your grade is invalid."<<FG<<endl;
cout<<"There is something wrong";
getch();
return 0;
}
Program 20

#include<iostream>
using namespace std;
int main()
{
char ch;
int number;
cout<<"Enter any alphabet letter: ";
cin>>ch;
switch ch
{
case 'a':
case 'A':
cout<<"Vowel";
break;
case e:
case 'E':
cout<<"Vowel";
break;
case i:
case I
cout<<"Vowel";
break;
case 'o':
case 'O':
cout<<"Vowel";
break;
case 'u':
case 'U':
cout<<"Vowel";
break;
default:
if (isdigit(ch))
cout<<"Entered character is a numeric character"
else
cout<<"Consonant";
}
Program Error Encountered Modified Codes Output
No.
(Syntax/Logical Error)

17
none else

cout << "You entered a letter!";

18 cout(("Enter the number: "<<endl; Cout<<"Enter the number: "<<endl;

cin))num; Cin>>num;

cout(("The number "<<num<<" is Cout<<"The number "<<num<<" is


even."); even.";

cout("The number ")num()" is Cout<<"The number "<<num<<" is


odd."; odd.";

19 #include<iostream.h> add "using namespace std;"

remove ".h" in
#include<conio.h> "#include<iostream.h>"

int name[15]; char name[15];

clrscr() cin>>PG;

cin<<PG; cin>>FG;

cin>>FFG; if (GA>=75 && GA<=100)

if (GA<=75 && GA<=100) cout<<"Your grade is "<<GA<<endl;

You might also like