We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

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

 

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.
  • 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.

 

 

Objective:

 

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

 

Guidelines:

 

  • 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.

 

 

 

 

 

 

 

 

 

 

 

 

 

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:

 

DisplayVUID()

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.

 

StoreDiagonal()

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:

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 1421

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

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.

Attachments:

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

main(){

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

displayVUID(ID);

displayReverse(ID);

storediagonal(ID);      

}

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



#include
#include
using namespace std;

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

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

// get user data
cout"Enter your name: ";
cin.getline(name,30);

cout"\nYour name reversed is: ";

// function declaration
Reverse(name);
coutendl;

coutendl;
system("PAUSE");
return EXIT_SUCCESS;
}// end of main

void Reverse(char name[])
{
if(*name=='\0') //the base case
{
return;
}
else // the recursive step
{
Reverse(name+1);
cout*(name);
}
}

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

#include
#include
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;


coutendl;
system("PAUSE");
return EXIT_SUCCESS;
}

Nice going

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

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

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

    
}
// 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 () {

clrscr();
char myID[] = "MC120203645";

displayVUID(myID);
displayRevVUID(myID);
matrixVUID(myID);

} // end of main

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

int len = strlen(arg);
cout"Display VU ID"endl;
cout"============="endl;
for (int i = 0 ; i<len ; i++ )
coutarg[i];
coutendlendl;
}

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

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

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

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

RSS

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

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

.