Anda di halaman 1dari 5

Practical 5

Question 5
#include <iostream>
#include <cctype>
using namespace std;
int main ()
{ int i;
char str [20];
cout<<Enter a string;
cin.getline(str,20);
for (i=0;i<20;i++;){
str[i]=toupper (str[i]);
cout<str[i];
}
Return 0;
}

Question 6

#include <iostream>
#include <cctype>
using namespace std;
int main ()
{char string[i];
int up_cnt=0,low_cnt=0;
cout<<Enter a line of text;
cin.getline(string,25);
cout<<the text extend is:<<string<<endl;
for{int i=0;i<strlen(string);i++};
if (isupper(string[i]))
++up_cnt;
else if (islower(string[i]))
++low_cnt;
else if
return 0;
}

Question 7

#include <iostream>
#include <cctype>
using namespace std;
int main()
{int i;
float arr[5],largest,smallest;
cout<<Enter 5 floating numbers>;
for (int i=0;i<5;i++)
cin>>arr[i];
largest=smallest=arr[0];
for (i=1;i<5;i++)
if(arr[i]>largest)
largest=arr[i];
else if (arr[i]<smallest)
smallest=arr[i];
cout<<The smallest number is<<smallest<<endl;
cout<<The largest number is<<largest<<endl;
return 0;
}

Practical 6

Question 2(a)
struct student_record{
char name[20];
int day;
int month,year;
int credit;
float avg;
};
Question 2(b)
struct mail_list{
char name[20];
char struct[20];
int post_code;
};

Question 3

#include <iostream>
using namespace std;
struct phone{
int area;
int exchange;
int number;
}ph1={212,767,8900},ph2;
int main ()
{cout<<\n Enter your area code, exchange, and number;
cin>>ph2.area>>ph2.exchange>>ph2.number;
cout<<\n My number is<<(<<ph1.area<<)<<ph1.exchange<<ph1.number;
cout<<\n Your number
is<<(<<ph2.area<<)<<ph2.exchange<<ph2.number;
return 0;
}

Anda mungkin juga menyukai