Icp Assignment#4 Wasim
Icp Assignment#4 Wasim
Icp Assignment#4 Wasim
COMPUTER
PROGRAMMING
COURCE CODE#CSC102
ASSIGNMENT#4
SUBMITTED TO: SIR NASIR MEHDI
Q.NO 1
#include <iostream>
int main()
double alpha[50],sqr,cube;
int i,j,d;
alpha[i] = i * i;
sqr+=alpha[i];
alpha[d] = d * d * d;
cube+=alpha[d];
}
INTRO TO COMPUTER PROGRAMMING
int a=0;
a++;
cout << "The square of the first 25 numbers is: " << sqr << endl;
cout << "The triple of the last 25 numbers is: " << cube << endl;
system("pause");
return 0;
Q.NO2
#include <iostream>
int main()
float avg;
string name[100];
int marks[100],i,sum=0,n;
cout<<"Enter the number of students you have to enter the name and
mark\n";
cin>>n;
for(i=0;i<=n;i++)
cin>>name[i];
cin>>marks[i];
sum+=marks[i];
avg=sum/n;
cout<<"\nName and marks of all the students whose test scores are below the
class average\n";
for(i=0;i<=n;i++)
INTRO TO COMPUTER PROGRAMMING
{
if(marks[i]<avg)
cout<<name[i]<<" "<<marks[i]<<endl;
cout<<"Name and marks of all the students having the highest score class
Average\n";
for(i=0;i<=n;i++)
if(marks[i]>avg)
cout<<name[i]<<" "<<marks[i]<<endl;
Q.NO3
#include <iostream>
int i,arr1[100],arr2[100],arr3[100],n1,n2;
AddArrays(arr1,arr2,arr3);
int a,i,n1,n2,n3;
cin>>n1;
for(i=0;i<n1;i++)
cin>>a1[i];
cin>>n2;
cin>>a2[i];
for(i=0;i<n1;i++)
a3[i]=a1[i];
for(a=1;a<n2;a++,i++)
a3[i]=a2[a];
n3=n1+n2;
for(i=0;i<n3;i++)
cout<<i+1<<"Value "<<a3[i]<<"\n";
}
INTRO TO COMPUTER PROGRAMMING
Q.NO4
#include <iostream>
int main()
int ar[3][7],row,col,sum,t=0,least,greatest,avrg[7],avg;
for(row=0;row<3;row++)
for(col=0;col<7;col++)
cin>>ar[row][col];
for(row=0;row<3;row++,t++)
for(col=0;col<7;col++)
{
INTRO TO COMPUTER PROGRAMMING
sum+=ar[row][col];
avg=sum/7;
avrg[t]=avg;
least=greatest=avrg[0];
for(int i=0;i<7;i++)
if(least>avrg[i])
least=avrg[i];
if(greatest<avrg[i])
greatest=avrg[i];
for(int i=0;i<7;i++)
cout<<"\nThe least amount of food eaten during the week by any one
monkey = "<<least;
INTRO TO COMPUTER PROGRAMMING
cout<<"\nThe greatest amount of food eaten during the week by any one
monkey ="<<greatest;
Q.NO5
#include <iostream>
int arr[100];
int i;
int max=ar[0],index=-1;
for(i=0;i<n;i++)
if(max<ar[i])
index=i;
return index;
int main()
INTRO TO COMPUTER PROGRAMMING
{
int i,n,mx;
cin>>n;
for(i=0;i<n;i++)
cin>>arr[i];
mx=maxint(arr,n);