You are on page 1of 10

Name;

1. #include<iostream>

#include <math.h>

using namespace std;

int main()

float score[5];

float a;

float highest =score[0];

for(int i=0; i<5;i++){

cout<<"enter the "<<(i+1)<<" score "<<endl;

cin>>score[i];

for(int i=1; i<5;i++){

if( highest <= score[i])

highest=(score[i]);

else

highest=highest;

cout<<"\n the highest number is "<<highest<<endl;


for(int i=0; i<5;i++){

cout<<"the differnce b/n "<<(i+1)<<" score is";

a=(highest-(score[i]));

cout<<a<<endl;

return 0;

2.

#include<iostream>

#include <math.h>

using namespace std;

int main()

float score[10];

float a;

float highest =score[0];

float lowest =score[0];

for(int i=0; i<10;i++){

cout<<"enter the "<<(i+1)<<" score "<<endl;

cin>>score[i];

for(int i=1; i<10;i++){

if( highest <= score[i])

highest=(score[i]);

else

highest=highest;

if(lowest>score[i])
lowest = score[i];

else ;

cout<<"\n the highest number is "<<highest<<endl;

cout<<"the lowest value is "<<lowest<<endl;

a=highest;

highest=lowest;

lowest=a;

cout<<" ## after the swap ##"<<endl;

cout<<"\n the highest number is "<<highest<<endl;

cout<<"the lowest value is "<<lowest<<endl;

return 0;

3.

#include<iostream>

using namespace std;

int main()

int n;

float elm[n];

float a;

cout<<"enter the number of elments"<<endl;

cin>>n;

for(int i=0; i<n;i++){


cout<<"enter the "<<(i+1)<<" score "<<endl;

cin>>elm[i];

cout<<"\n before sorting "<<endl;

for(int i=0; i<n;i++){

cout<<elm[i]<<", ";

for(int i=0; i<n;i++){

for(int j=i+1; j<(n-1);j++)

if( elm[i]< elm[j]){

a=elm[i];

elm[i]=elm[j];

elm[j]=a;

cout<<"\n after sorting "<<endl;

for(int i=0; i<n;i++){

cout<<elm[i]<<", ";

return 0;

4.

#include<iostream>
using namespace std;

int main()

float temp[10][4];

float lowest= temp[0][0];

float highest = temp[0][0];

cout<<"enter the values"<<endl;

for(int i=0; i<10;i++)

for(int j=0;j<4;j++)

cout <<"enter city "<<i+1;

cout<<" temprature "<<j+1<<" ";

cin>>temp[i][j];

};

for(int i=0; i<10;i++)

for(int j=0;j<4;j++){

if(lowest>temp[i][j])

lowest = temp[i][j];

if( highest < temp[i][j])

highest=temp[i][j];

else ;

cout<<"the lowest value is "<<lowest<<endl;


cout<<"the highest value is "<<highest<<endl;

return 0;

5.

#include<iostream>

using namespace std;

int main ()

float mat1[4][3], mat2[3][5], mat3[4][5];

for( int i=0; i<4; i++ ){

for( int j=0; j<3; j++ )

cout<<"enter the 1st matrice"<<(i+1)<<"row"<<(j+1)<<"column";

cin>>mat1[i][j];

for( int i=0; i<3; i++ ) {

for( int j=0; j<5; j++ )

cout<<"enter the 2nd matrices"<<(i+1)<<"row"<<(j+1)<<"column";

cin>>mat2[i][j];

for( int i=0; i<4; i++ ) {

cout<<"||";

for( int j=0; j<3; j++ )

cout<<mat1[i][j]<<"\t";
cout<<"|| "<<endl;

cout<<"multiplied by"<<endl;

for( int i=0; i<3; i++ ) {

cout<<"||";

for( int j=0; j<5; j++ )

cout<<mat2[i][j]<<"\t";

cout<<"|| "<<endl;

for( int i=0; i<4; i++ ){

for( int j=0; j<5; j++ )

for (int k=0; k<3;i++)

mat3[i][j]=mat1[i][k]*mat2[k][j];

for( int i=0; i<4; i++ ) {

cout<<"||";

for( int j=0; j<5; j++ )

cout<<mat3[i][j]<<"\t";

cout<<"|| "<<endl;

6. #include<iostream>

#include<cstring>

using namespace std;

int main()

char word[20];
char pal[20];

gets(word);

strcpy(pal,word);

strrev(pal);

cout<<"its reverse is ## "<<pal<<" ## so it is ";

if(strcmpi(word,pal)==0)

cout<<"palindrome";

else

cout<<"not";

return 0;

7. #include<iostream>

#include<cstring>

#include <cctype>

using namespace std;

int main(){

char str[50];

char upper;

gets(str);

cout<<"first there was this ## "<<str<<" ## after uppercased :"<<endl;

for( int i=0; i< strlen(str); i++ ){

//cout<<"first there was this ## "<<str<<" ## after uppercased :"<<endl;

upper=toupper(str[i]);

cout<<upper;
}

a.

#include<iostream>

#include<string.h>

using namespace std;

int main ()

char str[50];

int count = 0, i;

cout << "Enter a string : ";

gets(str);

for (i = 0; str[i] != '\0';i++)

if (str[i] == ' ')

count++;

cout << "Number of words in the string are: " << count + 1;

return 0;

B. #include<iostream>

#include<string.h>

using namespace std;

int main ()

char str[50];

int count = 0, i;

cout << "Enter a paragraph : ";


gets(str);

for (i = 0; str[i] != '\0';i++)

if (str[i] == '.')

count++;

cout << "Number of sentence in the paragraph are: " << count ;

return 0;

You might also like