Header Ads

جميع حلول اسئلة الواجبات 16 سؤال سي بلاس بلاس المرحلة الثانية د.غسان 2016-2015



 هذه الاسئلة والاجوبة في الاسفل

Q1
#include<iostream.h>
Hamid();
main()
{
Hamid();
}
Hamid(){
int i,j,m,h,s;
h=0;
char a[5][4];
char c[28]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
for(i=0;i<5;i++)
for(j=0;j<4;j++)
cin>>a[i][j];
for(i=0;i<5;i++)
for(j=0;j<4;j++){
for(m=0;m<28;m++)
if(a[i][j]==c[m])
h=h+1;
}
s=i*j-h;
cout<<"capital is ="<<h<<"\n"<<"others is="<<s;
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q2

#include<iostream.h>
func();
main()
{
func();
}
func(){
int a;
cin>>a;
if((a>=90)&&(a<=100))
cout<<"4";
if((a>=80)&&(a<=89))
cout<<"3";
if((a>=70)&&(a<79))
cout<<"2";
if((a>=60)&&(a<69))
cout<<"1";
if(a<60)
cout<<"0";
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\

Q3
#include<iostream.h>
func();
main()
{
func();
}
func(){
int i,s,b,d ;
s=0;
d=1;
for(i=0;i<8;i++)
{
cout<<d<<"\t";
b=s;
s=d;
d=s+b;
}
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q4
#include<iostream.h>
fact();
main()
{
 fact();
}
 fact(){
 int x,n,f;
cin>>n;
f=1;
if(n>=12)
cout<<"no factoral";
else
for(x=1;x<=n;x++)
f=f*x;
cout<<"factoral="<<f;
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q5
#include<iostream.h>
#include<math.h>
func();
main()
{
func();
}
func(){
int x,y,z;
cin>>x>>y;
z=pow(x,y);

cout<<z;

}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q6
#include<iostream.h>
func();
main()
{
func();
}
func(){
int i ;
int a[6];
cout<<"enter the matrixs \n";
for(i=0;i<6;i++)
cin>>a[i];
for(i=5;i>=0;i--)
cout<<a[i];
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q7
#include<iostream.h>
#include<ctype.h>
func();
 main( )
{
func();
}
func(){
 char s [ ] = "abcd";
 cout << s << endl;

 for ( int i =0; i < 4; i++ )
 s [i] = char(toupper (s[i] ));

 cout << s;
 cout<<endl<<endl<<endl;
  char z [ ] = "ABCD";
 cout <<endl<< z << endl;

 for (  i =0; i < 5; i++ )
 z [i] = char(tolower (z[i] ));

 cout << z;
 }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q8
#include<stdio.h>
#include<iostream.h>
main()
{
int a[3][3],sum;
sum=0;
int i,j;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(a[i][j]%2!=0)
sum=sum+a[i][j];
cout<<sum;
}




^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q9
#include<iostream.h>
main()
{
int i,j;
int a[3][3];
cout<<"enter matrixs\n";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
for(i=0;i<3;i++)
for(j=0;j<3;j++){
if(i==j)
a[i][j]=0;
}
for(i=0;i<3;i++){
cout<<endl;
for(j=0;j<3;j++)
cout<<a[i][j];}
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q10
#include<iostream.h>
main()
{
int i,j;
int a[3][3],x;
int c[9];
cout<<"enter first matrixs"<<endl;
for( x=0;x<9;x++)
cin>>c[x];

for( x=0;x<9;x++)
for(i=0;i<3;i++){
cout<<"\n";
for(j=0;j<3;j++){
a[i][j]=c[x];
}
}
for(i=0;i<3;i++){
cout<<"\n";
for(j=0;j<3;j++){
cout<<a[i][j]<<"\t";}}}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q11
َ#include<iostream.h>
void shiftright(int myarray[],int size);

 main(void)
{
int myarray[] = {10, 3, 23,45,7,16,5,};
shiftright(myarray,7);
for(int i=0;i<7;i++)
{
cout<<myarray[i]<<' ';
}
}
void shiftright(int myarray[],int size)
{
int temp;
int temp1;
for (int i=0; i<(size -1); i++)
{
temp = myarray[i];
 myarray[i] = myarray[size-1];
myarray[size-1] = temp;
}
}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q12
#include<iostream.h>
main()
{
int i,j,min;
int a[3][3];
cout<<"enter matrixs"<<"\n";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
min=a[0][0];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(a[i][j]<min)
min=a[i][j];
cout<<"min="<< min;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Q13
#include<iostream.h>
#include<stdio.h>
main()
{
char str[20];
gets(str);
for(int i=0;i<20;i++)
if((str[i]==' ')||(str[i]=='\0'))
cout<<endl;
else
cout<<str[i];
}


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Q14
#include<iostream.h>
#include<stdio.h>
struct Employee_info
{ char name[25];
char address[20];
char country[29];
int age;
int phone;
}st[1];
main()
{
int i,j;
cout<<"enter his name\n";
gets(st[1].name );
cout<<"enter his address\n";
gets(st[1].address );
cout<<"enter his country\n";
gets(st[1].country );
cout<<"enter his age\n";
cin>>st[1].age;
cout<<"enter his phone\n";
cin>>st[1].phone;

cout<<"this employee his name is "<<st[1].name<<endl;
cout<<"this employee his address is "<<st[1].address<<endl;
cout<<"this employee his country is "<<st[1].country<<endl;
cout<<"this employee his age is "<<st[1].age<<endl;
cout<<"this employee his phone is "<<st[1].phone<<endl;
}



^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 

هناك تعليقان (2):