CS201 Assignment 1 Solution Fall 2018
#1
CS201 - Introduction to Programming

Assignment 1 Solution

Semester: Autumn 2018

Save the following code in devC++ as .cpp and press F11 to compile and run. 

Code:
#include <iostream>
#include <time.h>
#include <stdlib.h>

using namespace std;

void swapValue(int *val1, int *val2) {
int temp;
temp = *val1;
*val1 = *val2;
*val2 = temp;
}

void findMinNum(int number[]) {
int temp, i, j;
for(i = 0; i < 5; i++) {
for(j=i+1; j<5; j++) {
if(number[i] > number[j]) {
swapValue(&number[i],&number[j]);
}
}
}
cout <<"\nSorted Random Numbers are: ";
for(int i =0; i <5; i++) {
cout<< number[i] << '\t';
}
}

void genRandNum(int num []) {
srand( (unsigned)time(0) );
cout <<"\nRandom Numbers are: ";
for(int i=0; i < 5; i++) {
num[i] = rand()%100;
cout << num[i] << "\t";
}
}

main() {
cout <<"\t CS201 Indroduction to Programing" <<endl;
int random_num[5];
genRandNum(random_num);
cout <<endl;
findMinNum(random_num);
cout <<endl<<endl;
system("pause");
}
#2
C:\Program Files (x86)\Dev-Cpp\Lang\collect2.exe [Error] ld returned 1 exit status
ye error aa rha hai
#3
This appears to be an application error, try to uninstall devc++ and then reinstall to see if it works.
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS201 Assignment 1 Solution Fall 2019 Ayra Suleman 0 1,164 11-11-2019, 01:21 AM
Last Post: Ayra Suleman
  CS201 Assignment 3 Solution Spring 2019 Ayra Suleman 0 356 07-11-2019, 10:21 PM
Last Post: Ayra Suleman
  CS201 Assihgnment Mishi Khan 0 508 05-07-2019, 08:18 PM
Last Post: Mishi Khan
  CS201-MidTerm Past paper Mishi Khan 0 1,128 12-22-2018, 07:32 PM
Last Post: Mishi Khan
  CS201 Assignment 3 Solution Spring 2018 Pakistani 0 6,196 07-24-2018, 08:27 PM
Last Post: Pakistani
  CS201 Assignment 2 Solution Spring 2018 Admin 4 7,719 05-28-2018, 02:36 PM
Last Post: Pakistani
  Assignment Solution CS201 Spring 2018 Syra Younas 3 4,094 05-07-2018, 09:46 PM
Last Post: Admin
  Cs201 Syra Younas 2 3,684 05-05-2018, 11:01 AM
Last Post: Muhammad Yaseen
  CS201 GDB Solution 2017 Rubaisha(Moody Girl) 3 5,213 01-10-2018, 10:16 AM
Last Post: fahadmukhtar
  cs201 GBD no 1 solution fahadmukhtar 1 2,656 01-07-2018, 10:12 AM
Last Post: Admin



Users browsing this thread:
1 Guest(s)