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.

CS201 Introduction to Programming Assignment No. 02 Solution and Discussion Spring 2013 Due Date 15-05-2013

Assignment No. 02
Semester: Spring 2013

CS201: Introduction to Programming

Total Marks: 20


Due Date:15/05/2013



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.
  • Assignment is copied(partial or full) from any source (websites, forums, students, etc)


Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files or .exe file, no reward will be given in any case.





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


  • Basic concepts of C/C++ language and Programming
  • Dealing with Data types
  • For Loop
  • Expressions
  • Character Array
  • Functions
  • Multidimensional Integer Array




  • Code should be properly indented and well commented.
  • Follow C/C++ rules while writing variable names, function names etc
  • Use only dev-C++ for this assignment.
















Problem Statement:     


Write a C++ program that prints your VUID by using character array, then prints your VUID in reverse order by using character array and finally stores and displays the digits of your VUID at the diagonal of 9 x 9 Matrix by using two dimensional integer array.

You are required to perform these tasks with the help of following three functions:

  • DisplayVUID()
  • DisplayReverse(char [])
  • StoreDiagonal()


Detailed Description:


Description of above functions are as follows:



This function stores your VUID in character array (for example bc020455055) and simply prints it.


DisplayReverse(char [])

This function takes the character array as parameter having your VUID and displays it in reverse order.



This function stores the digits of your VUID at the diagonal of 9 x 9 matrix, for example VUID i.e. bc020455055   contains the digits 020455055, so you have to store these digits in the diagonal of the 9 x 9 matrix as follows:


Views: 1533

Replies to This Discussion

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.


tariq bhai hum cin ly kr value ni ly skty kya??

The following program declares two arrays.

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
// Array of five ints
int numbers[5];

// Array of four strings
string texts[4];

#include <string>

using namespace std;

int main(int argc, char *argv[])
// Array of five hundred ints
int *numbers = new int[500];

// Array of four hundred strings
string *texts = new string[400];

// Free the memory
delete [] numbers;
delete [] texts;

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
int numbers[] = {1, 2, 5, 10};

string texts[] = {"Apple", "Banana", "Orange"};

// Access element at index 0
cout numbers[0] endl;

// Access element at index 2
cout texts[2] endl;

pleas provide your best idea  to solve this assigment before due date....

Solution hints for the assignment no 2.

sab se pehle main se bhe pehle header files ko include karne ke baad aap function prototypes dein ge like


void displayVUID(char array[]);

void displayReverse(char array1[]);

void storediagonal(char array2);


uss ke bad faraz karin keh aapka main program yah hai


                             // yahan par aik char array declare karein aour uss mein apni id save kar lein like

        char ID[] = "MC1302xxxxxxxx";

                            // uss ke baad aap functions ko call kar lein bari bari  like





///////////////////// main ke curly brace band hone ke baad aap ne sab functions ki body define karni hai like

void displayVUID(char array[])


             // iss mein aap ne do kam karne hain, aik easy, dosra professional jo aap ka je chahy aap kar sakte hain

            // easy kam

          //  aap ko apni apni id ke characher ki tadad maloom hai, yani 11 characters

          // aap aik loop ki madad se unko print karwa lein  like

      for (int a=0;a<11;a++)

         cout array[a];

     cout endl;

           // hint for professional method, pehle aap string ki length maloom karein then aap loop ko 11 ki bajaey strength length tak chalaein

// display ka kam khatam



void displayReverse(char array1[])


 ///// iss mein ussi loop ko 11-1 se 0 tak chala lein ulta like

for (int b = 10; b>=0; b--)

   cout array1[b];

cout endl;



void storediagonal(char array2)


yeh wala portion zara tricky hai, main solve nahi karounga sirf hint dounga, tahkeh aap log thora sochein,

hints, 9 by 9 ki aik arrary declare karein

aour jahan row aour column ki value same ho jaey wahan aap id ka character store karwa dein



I hope it will help

//Another way to reverse Array Char...Not solution..only guideline

using namespace std;

// function prototype
void Reverse(char name[]);

int main()
// declare variable
char name[30];

// get user data
cout"Enter your name: ";

cout"\nYour name reversed is: ";

// function declaration

}// end of main

void Reverse(char name[])
if(*name=='\0') //the base case
else // the recursive step

//Idea for printing an array chars in Reverse.....Its not Solution...a guideline...

using namespace std;

char* strrev( char* s )
char c;
char* s0 = s - 1;
char* s1 = s;

/* Find the end of the string */
while (*s1) ++s1;

/* Reverse it */
while (s1-- > ++s0)
c = *s0;
*s0 = *s1;
*s1 = c;

return s;

int main()
char message[] = "Hello world!";

cout "message = " message endl;
cout "egassem = " strrev( message ) endl;


Nice going

Only idea not a full solution............

#include <iostream>
#include <stdlib.h>
using namespace std;
void DisplayVUID();

void DisplayReverse(char[],int);
int main(){
    char VuidReverse[12] = {'M','C','1','2','0','4','0','4','1','4','0'};

// Ready Function
// Display Function
void DisplayVUID(){
    char VUID[12] = "MC120404140";
    cout "My VUID is: ";
    for(int i=0; i<12; i++){
        cout VUID[i];
// Reverse Function 
void DisplayReverse(char* VuidReverse, int arraysize){
    cout "\nMy VUID in reverse order: ";
    for(int i = arraysize - 1; i>=0; i--){
        cout VuidReverse[i];

# include <iostream.h>
# include <stdlib.h>
# include <string.h>
# include <conio.h>

// ****** Function Prototype *******
void displayVUID(char arg []);
void displayRevVUID(char ar []);
void matrixVUID(char str[]);

// ****** Main Function *******
void main () {

char myID[] = "MC120203645";


} // end of main

// ****** Display VU ID ********
void displayVUID(char arg[]){

int len = strlen(arg);
cout"Display VU ID"endl;
for (int i = 0 ; i<len ; i++ )

// ****** Display Reverse VU ID ********
void displayRevVUID(char arg[]){

int len = strlen(arg);
cout"Display Reverse VU ID"endl;
for (int i = len-1 ; i>=0 ; i-- )

//******** MATRIX *******
void matrixVUID(char str[]){

cout"Display Matrix VU ID"endl;
int len = strlen(str);
for (int i = 0 ; i<len ; i++){
for (int j = 0 ; j<len ; j++){
if (i == j)
coutstr[i]" ";
cout"0 ";
} // end of inner loop
} // end of outer loop
} // end of function


Looking For Something? Search Below

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

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