CS201 Assignment 2 Solution Spring 2018
#1
CS201 - Introduction to Programming
Assignment 2
Semester: Spring 2018

Assignment

Write a program in C++ that will ask some programming related questions () from user and rank user according his / her answers in one of following categories:
 
1-     Beginner level
2-     Intermediate level
3-     Advanced level
 
For this purpose, your program will ask three questions from the user (as given in the screenshots below), record their response in the form of true and false (as or F) and store it in a character array using for loop.
 
You have to create a function named computeUserLevel () and pass that array to this function and receive the array as pointer within the function declaration. The function will determine and print the result that whether you are a beginner, intermediate or advance level user. If a user is not able to correctly answer any of the questions then user level will be set as beginner.
 
 
Note: Only use the following programming constructs in your program:
 
1.     A Character Array
2.     For Loop
3.     Switch Statement
4.     Function (Call by reference – receive array by using pointers)
5.     If else (only allowed in function)
 
Otherwise your marks will be deducted accordingly.

Solution:


Code:
#include <iostream>
using namespace std;

void computeUserLevel (char *) ;

int main()
{
    cout<<"\t\tProgram To Predict User Programming Level"<<endl;
char Y [4];
for (int k=0; k<=0; k++)
{
cout<<"Q: Switch is a loop?\nA: ";
cin>> Y[0];
cout<<"Q: Pointers store memory addresses?\nA: ";
cin>> Y[1];
cout<<"Q: Semicolon after for loop is an error?\nA: ";
cin>>Y[2];
}
computeUserLevel(Y);
return 0;
}
void computeUserLevel (char *ptr)
{
if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 'f')
{
cout<<"Your level is advanced";
}
else if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 't')
{
cout<<"Your level is Intermediate";
}
else
cout<< "Your level is Beginner";
}

Save the code in devc++ with .cpp extension and press F11 to compile and run. 



Good Luck!
#2
Sad 
hello !!
plz inform me that how yo give input ?
#3
thankx
#4
(05-24-2018, 10:16 PM)Admin Wrote: CS201 - Introduction to Programming
Assignment 2
Semester: Spring 2018

Assignment

Write a program in C++ that will ask some programming related questions () from user and rank user according his / her answers in one of following categories:
 
1-     Beginner level
2-     Intermediate level
3-     Advanced level
 
For this purpose, your program will ask three questions from the user (as given in the screenshots below), record their response in the form of true and false (as or F) and store it in a character array using for loop.
 
You have to create a function named computeUserLevel () and pass that array to this function and receive the array as pointer within the function declaration. The function will determine and print the result that whether you are a beginner, intermediate or advance level user. If a user is not able to correctly answer any of the questions then user level will be set as beginner.
 
 
Note: Only use the following programming constructs in your program:
 
1.     A Character Array
2.     For Loop
3.     Switch Statement
4.     Function (Call by reference – receive array by using pointers)
5.     If else (only allowed in function)
 
Otherwise your marks will be deducted accordingly.

Solution:


Code:
#include <iostream>
using namespace std;

void computeUserLevel (char *) ;

int main()
{
    cout<<"\t\tProgram To Predict User Programming Level"<<endl;
char Y [4];
for (int k=0; k<=0; k++)
{
cout<<"Q: Switch is a loop?\nA: ";
cin>> Y[0];
cout<<"Q: Pointers store memory addresses?\nA: ";
cin>> Y[1];
cout<<"Q: Semicolon after for loop is an error?\nA: ";
cin>>Y[2];
}
computeUserLevel(Y);
return 0;
}
void computeUserLevel (char *ptr)
{
if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 'f')
{
cout<<"Your level is advanced";
}
else if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 't')
{
cout<<"Your level is Intermediate";
}
else
cout<< "Your level is Beginner";
}

Save the code in devc++ with .cpp extension and press F11 to compile and run. 



Good Luck!

Asslama o alaikum 
bro es ki kon c file sumit krwani hy source or exe?

Asslama o alaikum
Brother es ki kon c file summit krawani hy .cpp or exe

(05-27-2018, 12:06 PM)Anaah Rana Wrote: hello !!
plz inform me that how yo give input ?

Install DEV c++ 
then do copy solution from here and past in new project dev c++ and press F11 for compile save the project and give answer with t or f
#5
(05-28-2018, 01:32 PM)Ali Nawaz Wrote:
(05-24-2018, 10:16 PM)Admin Wrote: CS201 - Introduction to Programming
Assignment 2
Semester: Spring 2018

Assignment

Write a program in C++ that will ask some programming related questions () from user and rank user according his / her answers in one of following categories:
 
1-     Beginner level
2-     Intermediate level
3-     Advanced level
 
For this purpose, your program will ask three questions from the user (as given in the screenshots below), record their response in the form of true and false (as or F) and store it in a character array using for loop.
 
You have to create a function named computeUserLevel () and pass that array to this function and receive the array as pointer within the function declaration. The function will determine and print the result that whether you are a beginner, intermediate or advance level user. If a user is not able to correctly answer any of the questions then user level will be set as beginner.
 
 
Note: Only use the following programming constructs in your program:
 
1.     A Character Array
2.     For Loop
3.     Switch Statement
4.     Function (Call by reference – receive array by using pointers)
5.     If else (only allowed in function)
 
Otherwise your marks will be deducted accordingly.

Solution:


Code:
#include <iostream>
using namespace std;

void computeUserLevel (char *) ;

int main()
{
    cout<<"\t\tProgram To Predict User Programming Level"<<endl;
char Y [4];
for (int k=0; k<=0; k++)
{
cout<<"Q: Switch is a loop?\nA: ";
cin>> Y[0];
cout<<"Q: Pointers store memory addresses?\nA: ";
cin>> Y[1];
cout<<"Q: Semicolon after for loop is an error?\nA: ";
cin>>Y[2];
}
computeUserLevel(Y);
return 0;
}
void computeUserLevel (char *ptr)
{
if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 'f')
{
cout<<"Your level is advanced";
}
else if (*ptr == 'f' && *(ptr+1) == 't' && *(ptr+2) == 't')
{
cout<<"Your level is Intermediate";
}
else
cout<< "Your level is Beginner";
}

Save the code in devc++ with .cpp extension and press F11 to compile and run. 



Good Luck!

Asslama o alaikum 
bro es ki kon c file sumit krwani hy source or exe?

Asslama o alaikum
Brother es ki kon c file summit krawani hy .cpp or exe

(05-27-2018, 12:06 PM)Anaah Rana Wrote: hello !!
plz inform me that how yo give input ?

Install DEV c++ 
then do copy solution from here and past in new project dev c++ and press F11 for compile save the project and give answer with t or f

Brother read the instructions from the assignment file. I think you have to submit the solution is a Word file. Write the code there and also include the captured screenshots.
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS201 Assignment 3 Solution Spring 2018 Pakistani 0 1,016 07-24-2018, 08:27 PM
Last Post: Pakistani
  Assignment Solution CS201 Spring 2018 Syra Younas 3 1,809 05-07-2018, 09:46 PM
Last Post: Admin
  Cs201 Syra Younas 2 1,286 05-05-2018, 11:01 AM
Last Post: Muhammad Yaseen
  CS201 GDB Solution 2017 Rubaisha(Moody Girl) 3 1,965 01-10-2018, 10:16 AM
Last Post: fahadmukhtar
  cs201 GBD no 1 solution fahadmukhtar 1 1,528 01-07-2018, 10:12 AM
Last Post: Admin
  CS201 Assignment 2 Solution Fall 2017 Admin 0 1,139 11-22-2017, 09:09 PM
Last Post: Admin
  CS201 VIVA Questions and Answers Pakistani 1 7,326 02-06-2017, 05:26 PM
Last Post: Admin
  CS201 Assignment#2 Solution by Aly Hamza Aly Hamza 0 2,519 06-23-2016, 02:55 PM
Last Post: Aly Hamza
  CS201 Spring 2016 Assignment #1 Solution Aly Hamza 2 2,558 05-11-2016, 10:18 AM
Last Post: Rubaisha(Moody Girl)



Users browsing this thread:
1 Guest(s)