Professional Documents
Culture Documents
ID: 160222
Class: BEEE-VI-A
LAB NO # 01
TASK #1
#include<iostream>
int main()
char choice;
do
int a=10;
int b=20;
cout<<a<<endl;
cout<<b<<endl;
cout<<&a<<endl;
cout<<&a<<endl;
int *first_ptr;
first_ptr=&a;
cout<<"value stored in pointer is:"<<*first_ptr<<endl;
first_ptr=&b;
int*second_ptr;
second_ptr=first_ptr=&a;
*first_ptr=30;
cout<<a<<endl;
*second_ptr=40;
cout<<a;
cin>>choice;
while(choice=='y'||choice=='Y');
Task# 2
#include <iostream>
int main()
char choice;
do
{
int a,b;
cin>>a;
cin>>b;
cout<<"let's SWAP!"<<endl;
swap(&a,&b);
cin>>choice;
}while(choice=='Y'||choice=='y');
return 0;
int c;
c=*ptr1;
*ptr1=*ptr2;
*ptr2=c;
Task #3
#include <iostream>
if (operation==1)
int A=*num;
A++;
if (operation==2)
int A=*num;
A--;
}
int main ()
char choice;
do{
int num;
cin>>num;
int *ptr=#
int operation;
cin>>operation;
IncrementDecrement(&num,operation);
cin>>choice;
}while(choice=='Y');
}
Task#4
#include <iostream>
int A=*ptr;
int fact=1;
fact=fact*i;
return fact;
int main ()
char choice;
do{
int num;
cin>>num;
cin>>choice;
while(choice=='Y');
Task#5
#include <iostream>
int main ()
char choice;
do
double arr[5]={0,0,0,0,0};
for (int i=0;i<=4;i++)
cin>>arr[i];
cin>>choice;
}while(choice=='Y');
Task#6
#include <iostream>
int main ()
char choice;
do{
int arrA[10]={10,11,12,13,14,15,16,17,18,19};
int arrB[10]={0};
arrB[k]=arrA[k];
cin>>choice;
}while(choice=='Y');
return 0;
Task#7
#include <iostream>
int main ()
char choice;
do{
int arrA[10]={10,11,12,13,14,15,16,17,18,19};
int arrB[10]={0};
arrB[k]=arrA[k];
cin>>choice;
}while(choice=='Y');
return 0;
Task#8
#include <iostream>
int main(){
double arr1[10]={10,20,30,40,50,60,70,80,90,100};
int a=0;
for (int i=0;i<10;i++){
cout<<arr1[i]<<endl;
a=a+arr1[i];
system("pause");
return 0;
cin>>choice;
}while(choice=='Y');
return 0;
}
Task#9
#include <iostream>
int main()
int arr1[10]={5,3,2,7,8,4,4,2,9,0};
int a;
cout<<arr1[i]<<endl;
a=arr1[0];
arr1[0]=arr1[8];
arr1[8]=a;
a=arr1[1];
arr1[1]=arr1[9];
arr1[9]=a;
cout<<arr1[i]<<endl;
}
cout<<"size of array = "<<sizeof(arr1)/sizeof(arr1[0])<<endl;
system("pause");
return 0;
Task #10
#include <iostream>
int main()
int flag=0;
int a;
int arr1[10];
cin>>arr1[i];
cin>>a;
cout<<"index at "<<i<<endl;
flag=1;
if (flag==0){
system("pause");
return 0;
Task#11
#include <iostream>
#include <string.h>
int main(){
char a[30]="check";
char b[10]={'a','b','c','\0'};
char c[30];
cout<<c;
system("pause");
return 0;
END