Activity 17 20
Activity 17 20
BERCASIO
Section: BSIT M21
Subject: COMPRO1
Day 5 Activity
Program 17
#include<iostream>
int main ()
{
char ch;
cout << " Enter a Character: ";
cin >> ch;
else
{
cout << "You entered a letter!";
}
return 0;
}
Program 18
#include<iostream>
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
cin))num; Cin>>num;
remove ".h" in
#include<conio.h> "#include<iostream.h>"
clrscr() cin>>PG;
cin<<PG; cin>>FG;