HOME ASSIGNMENT FOR "XI C ++" COMPUTER SCIENCE 2013-14
//CRACK TOUGH NUTS IN c++
Test your skills in C++ PART-1
1.Write the Smallest Program in C++ ?
2.Identify the errors if any (Give explanation also ):
[A]
main(){
return 5;}
[B]
int main(){
return 5;}
[C]
int main(){
return; }
[D]
void main(){
return;}
[E]
char main(){
char c=65;
return c;}
[F]
int main(){
char c=65;
return c;
}
[G]
main(){
char c=65;
return c;}
[H]
main(){
char c=65;
return 0.6;}
[I]
int main(){
return int(5.8999);
}
[J]
int main(){
return 5.8999;}
3. Write a C ++
Program To Display Hello Without Using Semicolon (Explain each line of code
also)
4. find out the errors in the below given code :
#include<iostream.h>
#include<conio.h>
main()
{int _______________x=10,____________1111=20,1;
//MULTIPLE
UNDERSCORES are use as name of variable here
cout<< _______________x<<____________1111;
getch();}
5. Find out the output and explain it also line by line
#include<iostream.h>
#include<conio.h>
main()
{
int y;
//comma operator use
y=(10,20,30,40);
cout<<y;
y=10,20,30,40;
cout<<y;
int x =600;
y=(x/10+20,x*5+30,x-50/5);
cout<<y;
y=x/10+20,x*5+30,x-50/5;
cout<<y;
getch();}
Q6.Find the output and explain the ouput …
#include<iostream.h>
#include<conio.h>
void main()
{
unsigned char i;
i=260; //0----- 255
cout<<int(i);
getch();}
Q7.Find the output and explain the ouput …
#include<iostream.h>
#include<conio.h>
void main(){
signed char i;
i= -130;
cout<<int(i);
getch();}
Q8.Find the output and explain the ouput …
void main(){
short i;
i= -32770;
cout<<i;
getch();}
Q9.Find the output and explain the ouput …
#include<iostream.h>
#include<conio.h>
void main(){
int i=4;
cout<<"\n NOTE : << output operator inserts
value from left to right to the cout object.
\n"
" \n
but...Expressions/values to be inserted for display are executed/evaluated from
right to left direction \n\n";
cout
<<"\n Final value
of i = "<<i
<<"\n Value of
cout<<++i<<i<<++i<<i++
= "<<++i<<i<<++i<<i++
<<"\n Starting value
of i= "<<i;
getch();}
Q10.Find output and explain it also.s
#include<iostream.h>
#include<conio.h>
void main(){
int i=4;
int x=i++ + i++;
int y=++++++++i;
int z =++++i +
++++++i; //copiler gets mad---:-)
performs left to right
cout<<"\n x "<<x<<" y =
"<<y<<"
z
"<<z<<" i
="<<i;
int a,b,c,d;
a=i++ + i++;
b=++i +
++i; //++ perform right to left--correct
as per precedence rule
c=++i + i++;
d=i + ++i;
cout<<"\n a "<<a<<" b =
"<<b<<"
c
"<<c<<"
d "<<d<<" i ="<<i;
getch();}
// *******************THE END**PART-1*******************//
/* It is a HOME ASSIGNMENT FOR "XI C++" COMPUTER SCIENCE 2013-14
Submit it on Home work book on or before 17th August 2013. */