Anda di halaman 1dari 6

STRUCTURE PROGRAMS:

#include <iostream>
using namespace std;
struct key
{
int dd,mm,yy;
};
void main()
{

key k;

cout << "enter the date of birth" << endl;


cin >>k.dd;
cout << "enter the month of " << endl;
cin >>k.mm;
cout << "enter the year of " << endl;
cin >>k.yy;
cout << "date of birth in DD/MM/YY" << endl;
cout <<k.dd << "/" << k.mm << "/" << k.yy << endl;

system("pause");

}
OOP CLASSES
#include<iostream>
using namespace std;
class talha
{
private:
int a, b, c;
public:
void in()
{
cout << "enter the three marks" << endl;
cin >> a >> b >> c;

}
int sum()
{
return a + b + c;
}
float avg()
{
return (a + b + c) / 3.0;

}
};
void main()
{
talha m;
int s;
float a;
m.in();
s = m.sum();
a = m.avg();
cout << "SUM=" << s << endl;
cout << "ANVERAGE=" << a << endl;
system("pause");
}
String
#1

#include<iostream>
using namespace std;
void main()
{
char str[50];
int i=0;
cout<<"ente the string:"<<endl;
cin.getline(str,50);
while(str[i]!='\0')
i++;
cout<<"the length of string:"<<i<<endl;
system("pause");

}
#2
#include<iostream>
using namespace std;
void main()
{
char str1[50],str2[50];
int i=0;
cout<<"ente the string:"<<endl;
cin.getline(str1,50);
while(str1[i]!='\0')
{
str2[i]=str1[i];
i++;
}
str2[i]='\0';
cout<<"the value string 1:"<<str1<<endl;
cout<<"the value of string 2:"<<str2<<endl;
system("pause");

}
#3
#include<iostream>
using namespace std;
void main()
{
char str[50];
int i,v;
i=v=0;
cout<<"enter the string"<<endl;
cin.getline(str,50);
while(str[i]!='\0')
{
switch(str[i])
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
v++;
}
i++;

}
cout<<"The strings has "<<v<<"vowels."<<endl;
system("pause");

}
#include<iostream>

using namespace std;


void main()
{
char line[80];
int uc,lc,uv,lv;
uc=lc=uv=lv=0;
cout<<"enter the sentence:"<<endl;
cin.get(line,80);
for(int x=0;line[x]!='\0';x++)
{

if(line[x]=='A'||line[x]=='E'||line[x]=='O'||line[x]=='U'||line[x]=='I')
uv++;
else
if(line[x]=='a'||line[x]=='e'||line[x]=='o'||line[x]=='u'||line[x]=='i')
lv++;
else if(line[x]>+65&&line[x]<=90)
uc++;
else if(line[x]>+97&&line[x]<=122)
lc++;
}
cout<<"UPER CASE Consonants="<<uc<<endl;
cout<<"LOWER CASE Consonants="<<lc<<endl;
cout<<"UPER CASE vowels="<<uv<<endl;
cout<<"LOWEER CASE vowels="<<lv<<endl;

system("pause");

Anda mungkin juga menyukai