0

Q13-not completed

#include<iostream.h>
#include<string.h>

int main (){

char s1[100]=”Hello World!”;
char s2[100]=”Welcome”;

char *ptr;

strcpy(s2,s1);

cout<<s1<<endl<<s2<<endl;

return 0;
}

void append(char *s){

}

0

Q11

#include<iostream.h>

int main(){

long value1=200000;
long value2;

long *lPtr;
lPtr=&value1;

cout<<*lPtr<<endl;

value2=*lPtr;

cout<<value2<<endl;
cout<<&value1<<endl;
cout<<&lPtr;

return 0;

}

0

Q14

#include<iostream.h>

int main(){

char vowel1[]=”AEIOU”;
char vowel2[]={‘A’, ‘E’, ‘I’, ‘O’, ‘U’, ”};

cout<<vowel1<<endl<<vowel2;

return 0;

}

0

Q12

#include<iostream.h>
void swap(float,float);

int main(){
float a, b;

cout<<“Enter #1: “;
cin>>a;
cout<<“Enter #2: “;
cin>>b;

cout<<endl<<“After swapping”<<endl;
swap(a, b);

return 0;
}

void swap(float x, float y){
float *ptr_x, *ptr_y;

ptr_x=&x;
ptr_y=&y;

float temp=*ptr_x;
*ptr_x=*ptr_y;
*ptr_y=temp;

cout<<“#1: “<<*ptr_x<<endl;
cout<<“#2: “<<*ptr_y;
}

0

Q9-not complete

#include<iostream.h>
int fibonacci(int);

int main(){

int N, i=1;

cout<<“Enter number of values to display\n”;
cin>>N;
if(N==1)
cout<<“0″;
if(N==2)
cout<<“0″<<endl<<“1″;
else{
for(int j=1;j<=N;j++){
cout<<fibonacci(i)<<endl;
}
}

return 0;
}

int fibonacci(int i){

return(i+fibonacci(i-1)+fibonacci(i-2));
}

0

Q8

#include<iostream.h>

int fac(int);
long number;

int main(){

cout<<“Enter a number”<<endl;
cin>>number;

for(int i=0;fac(i)<number;i++)
cout<<i<<endl;

return 0;
}

int fac(int x){
if(x==0 || x==1)
return(1);
else
return(x*fac(x-1));
}

0

Q7

#include<iostream.h>

long compute(long,long);

int main(){

long number, exp;

cout<<“Enter the number\n”;
cin>>number;

cout<<“\nEnter the exponent\n”;
cin>>exp;

cout<<compute(number, exp);

return 0;
}

long compute(long num, long pow){

if(pow==0)
return(1);

else{
return(num*compute(num, pow-1));
}
}