0% found this document useful (0 votes)
4 views8 pages

Assignment 2

The document contains six programming assignments submitted by Alliya Fatima for the Programming Fundamentals course. Each program demonstrates basic programming concepts such as conditional statements, loops, and user input in C++. The assignments include checking equality of integers, evaluating student marks, identifying days of the week, a drink selection menu, printing even numbers, and generating a pattern of letters.

Uploaded by

alliyafatima78
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)
4 views8 pages

Assignment 2

The document contains six programming assignments submitted by Alliya Fatima for the Programming Fundamentals course. Each program demonstrates basic programming concepts such as conditional statements, loops, and user input in C++. The assignments include checking equality of integers, evaluating student marks, identifying days of the week, a drink selection menu, printing even numbers, and generating a pattern of letters.

Uploaded by

alliyafatima78
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/ 8

Name: Alliya Fatima (BS-AI)

Subject: Programming Fundamentals

Roll no: BSAI9248206

Assignment : 2

Submitted to: Sir Shahid


Program 1:
#include<iostream>
using namespace std;
int main()
{
int num1,num2;
cout<<"Enter two integers: "<<endl;
cin>>num1>>num2;
if(num1==num2)
{
cout<<"The values are equal.";
}
else
{
cout<<"The values are not equal.";
}
return 0;
}

Program 2:
#include <iostream>
using namespace std;
int main()
{
int marks;
cout << "Enter the marks of the student (out of 100): ";
cin >> marks;
if (marks >= 0)
{
if (marks <= 100)
{
if (marks >= 40)
{
cout << "The student has passed." << endl;
}
else
{
cout << "The student has failed." << endl;
}
}
if (marks > 100) {
cout << "Invalid marks." << endl;
}
}
if (marks < 0)
{
cout << "Invalid marks entered. Marks cannot be negative." << endl;
}
return 0;
}

Program 3:
#include <iostream>
using namespace std;
int main() {
int daynum;
cout << "Enter a number(1-7): ";
cin >> daynum;
if (daynum==1)
{
cout << "Monday." << endl;
}
else if(daynum==2)
{
cout << "Tuesday." << endl;
}
else if(daynum==3)
{
cout << "Wednesday." << endl;
}
else if(daynum==4)
{
cout << "Thursday." << endl;
}
else if(daynum==5)
{
cout << "Friday." << endl;
}
else if(daynum==6)
{
cout << "Saturday." << endl;
}
else if(daynum==7)
{
cout << "Sunday." << endl;
}
else
{
cout << "Invalid input.Input numbers between 1-7" << endl;
}
return 0;
}
Program 4:
#include<iostream>
using namespace std;
int main()
{
int select;
cout<<"Drink Menu:"<<endl;
cout<<"1.Coffee"<<endl;
cout<<"2.Tea"<<endl;
cout<<"3.Juice"<<endl;
cout<<"4.Water"<<endl;
cout<<"Select from above options:";
cin>>select;
switch(select)
{
case 1:
cout<<"YOU HAVE SELECTED COFFEE"<<endl;
break;
case 2:
cout<<"YOU HAVE SELECTED TEA"<<endl;
break;
case 3:
cout<<"YOU HAVE SELECTED JUICE"<<endl;
break;
case 4:
cout<<"YOU HAVE SELECTED WATER"<<endl;
break;
default:
cout<<"Invalid selection"<<endl;
}
return 0;
}

Program 5:
#include <iostream>
using namespace std;
int main()
{
for (int i = 1; i <= 100; i++)
{
if (i % 2 == 0)
cout << i << " ";
}
cout << endl;
return 0;
}
Program 6:
#include<iostream>
using namespace std;
int main()
{
for(char i='A' ;i<='E' ;i++)
{
for(char j='A' ;j<=i ;j++)
{
cout<<j;
}
cout<<endl;
}
return 0;
}

You might also like