Assignment Question:
Write a C++ program that performs
the following tasks:
1- Print
your name, VU id, and list of courses you have selected in current semester.
2- Print
the names of all courses
you have selected in the
current semester.
3- Add
first numeric digit of your VU id to
the total number of courses selected.
4- Display
the result of sum on the
screen.
5- Print
“Welcome to CS201-Introduction to Programming” by using WHILE loop. Number of
iterations of WHILE loop
must be equal to sum calculated in point 4.
For example, suppose the student id
is BC123456781. Then by adding first digits of vu id=1, with number of courses
(suppose =4), we get sum= 5.
Sum = first digits of vu id + number
of courses
5 =
1 + 4
In this case, program should print
“Welcome to CS201-Introduction to Programming” 5 times.
Assignment Solution CS201 Spring 2022
#include <iostream>
using namespace std;
main()
{
int id1=200201234;
cout<<"MY name is Ahmed Ali" <<endl;
cout<<"My VU Id is BC"<<id1<<endl;
int n;
cout<<"1. Introduction to Programming"<<endl;
n=1;
cout<<"2. Dyanmics"<<endl;
n=n+1;
cout<<"3. Matlab"<<endl;
n=n+1;
cout<<"4. Statics"<<endl;
n=n+1;
cout<<"5. Calculus"<<endl;
n=n+1;
cout<<"6. Calculus"<<endl;
n=n+1;
cout<<"7. Calculus"<<endl;
cout<<"Total number of courses = "<<n <<endl;
int firstdigit=id1/100000000;
int addition;
cout<<"First digit of VU ID = "<<firstdigit <<endl;
addition = firstdigit+n;
cout<<"Sum of First figit of VUID and total courses = "<<addition <<endl;
cout<<"\n";
int i=1;
while(i<=addition)
{
cout<<i<<". Welcome to CS201 Introduction to Programming"<<endl;
i++;
}
return 0;
}
Want more info, please press the below button
`
0 Comments
Please write us. Please write in detail that how may we help you