Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


Assignment No. 03
Semester: Spring 2010

CS201: Introduction to Programming

 

Total Marks: 20

 

Due Date:18/05/2010

 

Instructions

Please read the following instructions carefully before submitting assignment:

It should be clear that your assignment will not get any credit if:

 

§         The assignment is submitted after due date.

§         The submitted assignment does not open or file is corrupt.

§         All types of plagiarism are strictly prohibited.

 

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in .doc (Word document) you will get zero marks.

 

Objective

The objective of this assignment is to provide hands on experience of using

§         Basic concepts of C++ language and Programming

§         Conditional statements of C language

§         Character arrays in c language

§         Pointers in C language

§         String manipulation functions

 

Guidelines

§         Code should be properly aligned and well commented.

§         Follow c/c++ rules while writing variables names, function names etc

§         Use only dev-C++ for this assignment.

§         Use appropriate c/c++ structure i.e. loop, if-else, switch statement etc to get inputs from user (Marks will be deducted if inappropriate structure will be used).

 

Assignment

 

Problem Statement: Recognizing and Splitting the string.

You are required to write a program that takes a phone number as input from the user and stores it as a string value. The phone number will consist of country code, city code and actual 7-digit number separated by “-”. User can enter the phone number in any order. Your program should be able to recognize the country code, city code and 7-digit number and display it in the following format.

Country code - City code – 7-digit number

 

 

Detailed Description:

 

1.  Take phone number as input from the user.

2.  The number should be stored as a string value.

3.  User can enter the phone number in any order for example 0092-333-1234567 or 333-0092-1234567 or 1234567-333-0092 etc.

4.  Program should be able to recognize country code, city code and 7-digit number from the string and display it in the right sequence.

 

 

Sample Output 1  

Enter the complete phone number : 0092-1234567-333

 

Country code is = 0092

City code is = 333

7-digit number is = 1234567

Phone number in correct sequence is = 0092-333-1234567

 

 

 

Sample Output 2

Enter the complete phone number : 1234567-321-0092

 

Country code is = 0092

City code is = 321

7-digit number is = 1234567

Phone number in correct sequence is  = 0092-321-1234567

 

 

Sample Output 3

Enter the complete phone number : 300-0092-9876543

 

Country code is = 0092

City code is = 300

7-digit number is = 9876543

Phone number in correct sequence is  = 0092-300-9876543

 

 

 

HINTS:

You can split the string into three parts and store each part as different string.

You should use strtok, strlen, and strcat functions for solving this assignment.

 

 

Please Discuss Here about this assignment. Thanks

Views: 67

Attachments:

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service