ݺߣ

ݺߣShare a Scribd company logo
Cpp c++ 2
#include<iostream.h>
void main ()
{
int sum=0;
for(int i=0; i<=50; i++)
{
sum+=i;
}
cout<<sum<<endl;
}
1275
#include<iostream.h>
void main ()
{
int x;
char n;
cin>>n;
x=n;
cout<<x;
}
A=65
#include<iostream.h>
void main()
{
int x;
cin>>x;
if(x<=50)
x=x+1;
x=x+1;
if(x<=5 {
x++;
x++;
}
cout<<"x :"<<x<<endl;
}
12 7
#include<iostream.h>
void main ()
{
int r ;
cout<<" you can enter any value
to exit enter 0 ";
while ( r!=0)
{
cout<<"n";
cin>>r;
}
}
For addtation For aganst
#include <iostream.h>
int main()
{
cout<<5+3/2+1<<endl; 7
cout<<(5+3)/(2+1)<<endl; 2
cout<<8%(3*4)+8/3-9<<endl; 1
cout<<8/(3*4+8/3-9)<<endl; 1
cout<<8%5<<endl; 3
cout<<8/5<<endl; 1
cout<<8*3+4/3<<endl; 25
}
#include <iostream.h>
int main()
{
int n,m;
cin>>n>>m;
while(n<m)
{
m=m-1;
if(m/n==0)
goto end;
else
continue;
}
end:
cout<<m<<n<<"nt";
return 0;
}
4>>7=44
5>>7=55
#include <iostream.h>
int main()
{
int x=0,i=1,m;
cout<<"i"<<"tn"<<"t"<<"y"<<endl;
while(true)
{
x+=i;
m=x*x;
cout<<i<<"t"<<x<<"t"<<m<<endl;
i++;
if(i>=6)
break;
}
return 0;
}
I x y
1 1 1
2 3 9
3 6 36
4 10 100
5 15 225
????? ??????
#include<iostream.h>
void main ()
{
int n;
cin>>n;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=n;j++)
cout<<i<<"*"<<j<<"="<<i*j<<"t
"<<endl;
}
}
#include<iostream.h>
void main ()
{
int n;
cin>>n;
if(n%2==0)
cout<<"even"<<endl;
else
cout<<"odd"<<endl;
}
Even and odd
C++
1.0
:
?C++.
?.
?C++.
?C++.
?C++. OmerAhmedSaeed
-
#include <iostream.h>
?C
?
Header FilesInclude
Files
?C
?iostream.h
?.hheader file
:
1(area = PI * r * r)
(circumference = 2 * PI * r.)
(r)5.2PI = 3.1415926
#include <iostream.h>
main()
{
float r, PI;
r = 5.2;
PI = 3.1415926;
cout<<"area = "<< PI * r * r<<"n";
cout<<"circumference = "<< 2 * PI * r;
}
2(length( )width. )
(perimeter = 2*(length+width)( )area=length*width)
#include <iostream.h>
main()
{
int length, width;
cout<<"length = "; cin>>length;
cout<<"width = "; cin>>width;
cout<<"perimeter = "<<2*(length+width)<<"n";
cout<<"area = "<<length*width;
}
3(m1, m2, m3, m4)
(avg = (m1+m2+m3+m4)/4)
#include <iostream.h>
main()
{
int m1, m2, m3, m4;
cout<<"Enter marks n";
cin>>m1>>m2>>m3>>m4;
cout<<"avg = "<< (m1+m2+m3+m4)/4;
}
4??????????
#include <iostream.h>
main()
{
cout<<"Abdulla Awad nnttt";
cout<<"BaitBoss zone ttt Yemeni";
}
1.5.
(Even( )Odd. )
#include <iostream.h>
read(int ar[]) {
cout<<"Enter 5 numbers:";
for(int i=0; i<=4; i++)
cin>>ar[i];
}
isEven(int x) {
if(x % 2 == 0) return 1;
return 0;
}
isOdd(int x) {
return (!isEven(x));
}
printEven(int ar[]) {
cout<<"Even numbers: ";
for(int i=0; i<=4; i++)
if(isEven(ar[i])) cout<<ar[i]<<" ";
cout<<endl;
}
printOdd(int ar[]) {
cout<<"Odd numbers: ";
for(int i=0; i<=4; i++)
if(isOdd(ar[i])) cout<<ar[i]<<" ";
cout<<endl;
}
main() {
int a[5];
read(a);
printEven(a);
printOdd(a);
int b[5];
read(b);
printEven(b);
printOdd(b);
}
#include<iostream>
using namespace std;
int larger(int,int);
void main()
{
int a=2,b=6;
cout<<larger(a,b)<<"is large"<<endl;
}
int larger(int x,int y)
{
if(x>y)
return x;
else
return y;
}
#include<iostream>
using namespace std;
int larger();
void main()
{
cout<<larger()<<"is larger"<<endl;
}
int larger()
{
int x=2,int y=6;
if(x>y)
return x;
else
return y;
}
1)
#include<iostream>
using namespace std;
int larger();
void main()
{
cout<<larger()<<"is larger"<<endl;
}
int larger()
{
int x=2,int y=6;
if(x>y)
return x;
else
return y;
}
#include<iostream>
using namespace std;
void line(char,int);
int main()

More Related Content

Cpp c++ 2

  • 2. #include<iostream.h> void main () { int sum=0; for(int i=0; i<=50; i++) { sum+=i; } cout<<sum<<endl; } 1275 #include<iostream.h> void main () { int x; char n; cin>>n; x=n; cout<<x; } A=65
  • 3. #include<iostream.h> void main() { int x; cin>>x; if(x<=50) x=x+1; x=x+1; if(x<=5 { x++; x++; } cout<<"x :"<<x<<endl; } 12 7 #include<iostream.h> void main () { int r ; cout<<" you can enter any value to exit enter 0 "; while ( r!=0) { cout<<"n"; cin>>r; } } For addtation For aganst
  • 4. #include <iostream.h> int main() { cout<<5+3/2+1<<endl; 7 cout<<(5+3)/(2+1)<<endl; 2 cout<<8%(3*4)+8/3-9<<endl; 1 cout<<8/(3*4+8/3-9)<<endl; 1 cout<<8%5<<endl; 3 cout<<8/5<<endl; 1 cout<<8*3+4/3<<endl; 25 } #include <iostream.h> int main() { int n,m; cin>>n>>m; while(n<m) { m=m-1; if(m/n==0) goto end; else continue; } end: cout<<m<<n<<"nt"; return 0; } 4>>7=44 5>>7=55
  • 5. #include <iostream.h> int main() { int x=0,i=1,m; cout<<"i"<<"tn"<<"t"<<"y"<<endl; while(true) { x+=i; m=x*x; cout<<i<<"t"<<x<<"t"<<m<<endl; i++; if(i>=6) break; } return 0; } I x y 1 1 1 2 3 9 3 6 36 4 10 100 5 15 225 ????? ?????? #include<iostream.h> void main () { int n; cin>>n; for(int i=0;i<=n;i++) { for(int j=0;j<=n;j++) cout<<i<<"*"<<j<<"="<<i*j<<"t "<<endl; } }
  • 6. #include<iostream.h> void main () { int n; cin>>n; if(n%2==0) cout<<"even"<<endl; else cout<<"odd"<<endl; } Even and odd
  • 7. C++ 1.0 : ?C++. ?. ?C++. ?C++. ?C++. OmerAhmedSaeed - #include <iostream.h> ?C ? Header FilesInclude Files ?C ?iostream.h ?.hheader file : 1(area = PI * r * r) (circumference = 2 * PI * r.) (r)5.2PI = 3.1415926 #include <iostream.h> main() { float r, PI; r = 5.2; PI = 3.1415926; cout<<"area = "<< PI * r * r<<"n"; cout<<"circumference = "<< 2 * PI * r; } 2(length( )width. ) (perimeter = 2*(length+width)( )area=length*width) #include <iostream.h> main() { int length, width; cout<<"length = "; cin>>length; cout<<"width = "; cin>>width; cout<<"perimeter = "<<2*(length+width)<<"n"; cout<<"area = "<<length*width; } 3(m1, m2, m3, m4) (avg = (m1+m2+m3+m4)/4) #include <iostream.h> main() { int m1, m2, m3, m4; cout<<"Enter marks n"; cin>>m1>>m2>>m3>>m4; cout<<"avg = "<< (m1+m2+m3+m4)/4; } 4?????????? #include <iostream.h> main() { cout<<"Abdulla Awad nnttt"; cout<<"BaitBoss zone ttt Yemeni"; } 1.5. (Even( )Odd. ) #include <iostream.h> read(int ar[]) { cout<<"Enter 5 numbers:"; for(int i=0; i<=4; i++) cin>>ar[i]; } isEven(int x) { if(x % 2 == 0) return 1; return 0; } isOdd(int x) { return (!isEven(x)); } printEven(int ar[]) { cout<<"Even numbers: "; for(int i=0; i<=4; i++) if(isEven(ar[i])) cout<<ar[i]<<" "; cout<<endl; } printOdd(int ar[]) { cout<<"Odd numbers: "; for(int i=0; i<=4; i++) if(isOdd(ar[i])) cout<<ar[i]<<" "; cout<<endl; } main() { int a[5]; read(a); printEven(a); printOdd(a); int b[5]; read(b); printEven(b); printOdd(b); } #include<iostream> using namespace std; int larger(int,int); void main() { int a=2,b=6; cout<<larger(a,b)<<"is large"<<endl; } int larger(int x,int y) { if(x>y) return x; else return y; } #include<iostream> using namespace std; int larger(); void main() { cout<<larger()<<"is larger"<<endl; } int larger() { int x=2,int y=6; if(x>y) return x; else return y; } 1) #include<iostream> using namespace std; int larger(); void main() { cout<<larger()<<"is larger"<<endl; } int larger() { int x=2,int y=6; if(x>y) return x; else return y; } #include<iostream> using namespace std; void line(char,int); int main()