0% found this document useful (0 votes)
15 views

Problem 1: Assignment

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Problem 1: Assignment

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT

PROBLEM 1
1. Write a C++ program to find the grade of a student. The below table shows the
grading system.

ANSWER
#include <iostream>
using namespace std;

int main() {
int number;
char A,B,C,D,E,F,grade;
cout<<"enter the number";
cin>>number;
if (number>100) {
cout<<"the score is out of range";
}
else
if (number>= 90)
{
grade = 'A';
}
else
{
if (number>=80)
{
grade = 'B';
}
else
{
if (number>=70)
{
grade = 'C';
}
else
{
if (number>=60)
{
grade = 'D';
}
else
{
if (number >=50)
{
grade = 'E';
}
{
grade = 'F';
}
}
}
}
cout<<(grade)<<endl;
}

return 0;
}

OUTPUT
PROBLEM 2
Write a C++ program to check one letter is vowel or consonant.

SOLUTION

//C++ Program to check whether alphabet is vowel or consonant


#include <iostream>
using namespace std;

int main()
{
char c;
cout<<"Enter an alphabet: ";
cin>>c;
//checking for vowels
if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||
c=='U')
{
cout<<c<<" is a vowel";
}
else
{
cout<<c<<" is a consonant";
}
return 0;
}

OUTPUT

You might also like