V1

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View V1 as PDF for free.

More details

  • Words: 940
  • Pages: 10
1. # include <stdio.h> main() { const int i = 100; int *p = &i; *p = 200; printf("%d\n",i); } 2. #define prn(a) printf("%d",a) #define print(a,b,c) prn(a), prn(b), prn(c) #define max(a,b) (a
case 1: while (( c = input[++i]) != '\1' && c!= '\0'); case 9: putchar('S'); case 'E': case 'L': continue; default: putchar(c);continue; } putchar(' ');

} putchar('\n'); }*/

/*6. # include <string.h> main() { int i=0; char *cat = "software\0contest"; while (strlen(*cat++)) { i++; printf("%d\n",i); } } 7. main() { enum tag{low='a',high='b',med='c'}; char try=low; printf("\nthe size of the variable=%d",sizeof(tag)); switch(try) { case 'a':printf("\nyou must print a"); case 'b':printf("\nyou must print b"); case 'c':printf("\nyou must print c"); } } 8. #include <string.h> main(){ char p[]="MalayalaM"; char t; int i,j; for(i=0,j=strlen(p);i<j;i++){ t=p[i]; p[i]=p[j-i]; p[j-i]=t; } printf("%s",p)� } �9. main() { # define MyDef 1 printf(&MyDef["a%sing"],&(MyDef-1)["Twist"]+'i'-0x69); } 10.

Fo� a� inpu� o� REC VERSION SWCONT $ writ� th� output.*/ /*void main() { myfunc(); } myfunc() { char a[80]; scanf("%s",a); if (!strchr(a,'$')) myfunc(); printf("%s",a); } 11.*/ /*main() { int a,b; a=0010; b=0100; a-=(b=(a+=b)-b); printf("a=%d b=%d",a,b); }*/ /*12. main() { struct xyz { int xyz;}; struct xyz xyz; xyz.xyz=10; printf("%d",xyz.xyz); } The output of the above code is a. b. c. d.

will not compile 10 100 none of the above

13. static int i=5; void main(void) �{ int sum=0; do { sum+=(1/i); }while (0 < i--); }

14. # include main() { char *x="This is a"; char y[]= "sitter"; char *z; z=(char *)malloc(sizeof(x)+sizeof(y)=1); strcpy(z,y); strcat(z,y); printf("%s+%s=%s",y,x,z); } 15. # define scanf "%s version software contest" main() { printf(scanf,scanf); } 16. #include <stdio.h> main() { int a=0,b=1; printf("%d",!(a ^= !( a ~= ( b >> 4 >> 4 << 2 ) ) ) ); } 17. MAIn() { int m=10; switch(m) { case 2+10/2*6-10-2 : printf("how are you"); case 2-10+6*5-2 : printf("i am here"); default:printf("i am not here"); } } 18. main() { char quote[]="all the best"; char *ptr1 = quote,*ptr2 = quote + sizeof(quote)-1; int i; for(i=0;ptr1!=ptr2;i++) { --ptr2; � printf("%c",*ptr1); printf("%c",*ptr2); ++ptr1; } printf("\n%d",i); }

19. # define PRINTX printf("%d\n",x) main() { int x=2,y,z; x*=3+2;PRINTX; x*=y=z=4;PRINTX; x=y==z;PRINTX; x==(y=z);PRINTX; } 20. main() { char c=65; switch(c) { case 65 : switch(c++) { case 65 :putchar('A'); break; case 66 :putchar('B'); break; } case 'B' : putchar('A'); break; } } .pa �21. main() { int i=1; clrscr(); switch(i) { do { case 1:printf("\nhello"); case 0:printf("hai"); }while (i--); } } 22. #include class questionclass { protected : int howru; public : void askquestion(int value) { howru = value; }

virtual void tellmehowur()=0; }; class answerclass : public questionclass { private : int iamfine; public : answerclass(int value) { iamfine = value; } void tellmehowur() { howru = iamfine; cout<<"The answer is "< class constclass { const int iremainthesame; public : constclass(int value) { iremainthesame= value; } void showvalue() { cout<<"The value of the variable is "<
24. #include class pvtdestructor { int canidestroythis; ~pvtdestructor() { canidestroythis = 0; cout<<"it works!!"<<endl; } public : pvtdestructor() { canidestroythis = 23; cout<<"in the constructor"<<endl; } }; main() { pvtdestructor object; } .pa �25. #include class base { protected : void function(double arg) { cout<<"The real value is "<<arg<<endl; } }; class derived : public base { public : void function(int arg) { cout<<"The integer value is "<<arg<<endl; } }; what would be the output in each of the following cases : (i) main() { derived dobject; float arg = 2.009; dobject.function(arg); } (ii) main() { derived dobj; base& bref = dobj;

}

float arg = 2.009; bref.function(arg);

26. #include class operclass { int i,j; public : operclass() { i = 21; j = 23; } void operator ++() { i++; j++; } }; main() { operclass obj; obj++; } �27. #include main() { int integer1 = 23, integer2 = 21; int &reftointeger; reftointeger = integer1; cout<<"the referred integer holds the value of "<
28. #include class shape { public : static float area ; virtual static void display_area() { cout<<"The area of the shape is "<<area; } }; class square : public shape { private : int side; public : square(int s) {

}

side = s; area = s*s ;

void display_area() { cout<<"The area of the square is "<<area; } }; main() { square sq(1); sq.display_area(); } .pa �29. #include class storageclass { static int si; const int ci; public : storageclass():ci(0) { } void constfun() const { ci++; si++; show(); } void show() const { cout<<"static int is "<<si<<endl; cout<<"const int is"< class staticlass { int data; public : staticlass() { data = 23;

} void show() { cout<<"the data value is "<

Related Documents

V1
May 2020 25
V1
May 2020 18
V1
July 2020 13
V1
June 2020 17
V1
May 2020 15
V1
July 2020 18