CSI 250L Lab 1, Spring 2012
American University of Science and Technology · Programming II Lab · 3 pages · Dr. Saeed Raheel
More CSI 250L files
- Lab 1 Solution · Spring 2012Lab · with solutionView
- Lab 10 Solution · Spring 2012Lab · with solutionView
- Lab 10 · Spring 2012LabView
- Lab 11 Solution · Spring 2012Lab · with solutionView
- Lab 11 · Spring 2012LabView
- Lab 12 Solution · Spring 2012Lab · with solutionView
- Lab 12 · Spring 2012LabView
- Lab 13 Solution · Spring 2012Lab · with solutionView
Show the text of this lab
American University of Science & Technology
Department Of Computer Science
CSI 250L – Computer Programming-II Lab
Fall 2011/2012
Lab Work 1
Part 1 - Introduction to the CSI 250L
I.
Introduction to the Computer Programming II Lab (CSI 250 L) objectives and
requirements.
II.
Explanation of the lab policies and procedures, as well as the Lab Syllabus and
grading policy. (Read and explain the Syllabus in details)
III.
Work on the C++ environment to show students the following steps:
1. Create a new Win32 Console Application empty project workspace.
2. Type and save the following c++ program as “program1.cpp”.
#include <iostream>
using namespace std;
int main( )
{
system("pause");
return 0;
}
3. Compile, link and execute the program. (explain each step)
4. Type “Return 0” instead of “return 0” and ask them to repeat step3.
Show them how to correct the compilation mistakes till they are able
to execute the program.
5. Type “int Main” instead of “int main” and ask them to repeat step
3.Show them the difference between the linking and compilation
errors.
6. Ask the student to remove “system("pause");”, and to repeat step 3.
Discuss with students the program execution results.
1
Part 2 - Trace the following programs:
#include<iostream>
using namespace std;
int main()
{
int A=4, B=1,C;
cout<<"A="<<A--<<"\nB="<<++B<<endl;
C=A+B;
cout<<"C="<<--C<<endl;
for(int i=0; i<=C;i++)
{
for(int j=0; j<=i;j++)
cout<<"*";
cout<<endl;
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
int arr_sum(int[],int);
void swap(int&,int&);
int main()
{int A[10],X=2,Y=4;
for(int i=0;i<10;i++)
{
A[i]=i;
cout<<"A["<<i<<"]="<<A[i]<<endl;
}
cout<<"the sum of the values stored in A is "<<arr_sum(A,10)<<endl;
cout<<"the value of x="<<X<<endl<<"the value of y ="<<Y<<endl;
swap(X,Y);
cout<<"the value of x="<<X<<endl<<"the value of y ="<<Y<<endl;
system("pause");
return 0;
}
int arr_sum(int arr[],int ds)
{int s=0;
for(int i=0;i<ds;i++)
s+=arr[i];
return s;
}
void swap(int &a, int &b)
{
int temp;
temp=a;
a=b;
b=temp;
}
2
Part 3 - Review Functions and arrays of integers
:
Write a program to allow the user to input N positive integers and store them in an array,
arr, of 100 cells.(let N be the first input by the user)
The program should print the content of arr sorted in ascending order.
Part 4 - Review Functions and arrays of characters
:
Write a program that inputs a word into an array S1. The program should store in an array
S2 the reverse of S1, and in S3 the content of S1 converted to capital letters.
3