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 3 Solution Spring 2018 Pakistani 0 1,463 07-24-2018, 08:27 PM
Last Post: Pakistani
  CS201 Assignment 2 Solution Spring 2018 Admin 4 4,529 05-28-2018, 02:36 PM
Last Post: Pakistani
  Assignment Solution CS201 Spring 2018 Syra Younas 3 2,353 05-07-2018, 09:46 PM
Last Post: Admin
  Cs201 Syra Younas 2 1,742 05-05-2018, 11:01 AM
Last Post: Muhammad Yaseen
  CS201 GDB Solution 2017 Rubaisha(Moody Girl) 3 2,239 01-10-2018, 10:16 AM
Last Post: fahadmukhtar
  cs201 GBD no 1 solution fahadmukhtar 1 1,791 01-07-2018, 10:12 AM
Last Post: Admin
  CS201 Assignment 2 Solution Fall 2017 Admin 0 1,365 11-22-2017, 09:09 PM
Last Post: Admin
  CS201 VIVA Questions and Answers Pakistani 1 7,518 02-06-2017, 05:26 PM
Last Post: Admin
  CS201 Assignment#2 Solution by Aly Hamza Aly Hamza 0 2,638 06-23-2016, 02:55 PM
Last Post: Aly Hamza
  CS201 Spring 2016 Assignment #1 Solution Aly Hamza 2 2,714 05-11-2016, 10:18 AM
Last Post: Rubaisha(Moody Girl)



Users browsing this thread:
1 Guest(s)