Posts

Showing posts with the label virtual univeristy assignment

CS201-VU- Multi Diemensional arrays in cpp with do while loop

Hello guys!  The following cpp program demonstrates the use of  two dimensional Arrays and do while loop;  comment below for any queries. #include <iostream> #include <stdlib.h> using namespace std; void showElements(float cov19data[][4]);  // functions definitions  double percentageDeath(float cov19data[][4], int userChoice); double percentageRecovered(float cov19data[][4], int userChoice); int main() { int selectedOption; float cov19data[7][4]   // defining two diemensional array { { 0, 560433, 22115, 32634}, { 1, 156363, 19899, 34211},  { 2, 84279, 10612, 0}, { 3, 82160, 3341, 77663}, { 4, 71686, 4474, 43894}, { 5, 56956, 1198, 3446}, { 6, 5374, 93, 1095} }; do {  // do while loop to run program untill user terminates it. showElements(cov19data);   // function call cout << "\n\n"; cout << "Press The Country Code To Calculate Perce...

complete example creating , updating and deleting a text file in C++

Hello From IQBAL , guys, we often come across situations to store little data in .txt file. in the code below i have covered:  creating txt file to store records of employees showing records from the file(reading file) updating salary of the employee(updating specific text in the file) deleting old file when program runs. An Employee Class with needed Methods your comments and suggestions are welcomed #include <iostream> #include <string> #include <fstream> #include <streambuf> #include <bits/stdc++.h>  using namespace std; class Employee{ public:   void add(string code,string name,int salary) {   cout<<"Employee: "<<name<<" with Salary :"<<salary<<" Addedd."; ofstream file;   file.open ("employee.txt",std::ios_base::app);   file <<code<<","<<name<<","<<salary<<";";   ...

printing Alphabets in a shape like diamond inside a square using C++

Image
Hello From IQBAL ! guys, after tiresome work i have produced the following code to print alphabets like below:   Below is the source code, feel free to comment your suggestions and corrections. #include <iostream> using namespace std; int main(void){     int a= 65;     char height = 'G'; // can get this as input via cin>>     int endchar = (int) height;     int rows, c, k;          rows =endchar-a-1; int steps = rows;     for (k=1; k<=rows+1; k++)     {      for(c=0; c<=steps; c++)     {     cout<<((char)(65+c));     }         for(c=1; c<=(2*k-2); c++)     {     cout<<" ";     }     if(k==1){         for(c=1; c<=rows; c++) {     cout<<((char)(endchar-c-1));     } ...