Question Set

1. If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h> int main() { char str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; }





Ask Your Doubts Here

Type in
(Press Ctrl+g to toggle between English and the chosen language)

Comments

  • By: guest on 01 Jun 2017 06.02 pm
    Step 1: char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; The variable str is declared as an pointer to the array of 6 strings. Step 2: printf("%d, %d", sizeof(str), strlen(str[0])); sizeof(str) denotes 6 * 4 bytes = 24 bytes. Hence it prints '24' strlen(str[0])); becomes strlen(Frogs)). Hence it prints '5'; Hence the output of the program is 24, 5 Hint: If you run the above code in 16 bit platform (Turbo C under DOS) the output will be 12, 5. Because the pointer occupies only 2 bytes. If you run the above code in Linux (32 bit platform), the output will be 24, 5 (because the size of pointer is 4 bytes).
Show Similar Question And Answers
QA->"A" can do a piece of work in 40 days. He works at it for 8 days and then B finished the work in 16 days. How long will they take to complete the work if they do it together?....
QA->A and B can finish a work 30 days if they work together. They worked together for 20 days and then B left. A finished the remaining work in another 20 days. In how many days A alone can finish the work?....
QA->A man is facing East, then the turns left and goes 10 m, then turns right and goes 5 m, then goes 5 m to the South and from there 5 m to West. In which direction is he, from his original place ?....
QA->Who built Char Minar?....
QA->When you click on Draw Table option,the mouse pointer changes to a....
MCQ->What will be the output of the program? #include<stdio.h> #include<stdarg.h> void fun1(char, int, int , float , char ); void fun2(char ch, ...); void (p1)(char, int, int , float , char ); void (p2)(char ch, ...); int main() { char ch='A'; int i=10; float f=3.14; char p="Hello"; p1=fun1; p2=fun2; (p1)(ch, i, &i, &f, p); (p2)(ch, i, &i, &f, p); return 0; } void fun1(char ch, int i, int pi, float pf, char p) { printf("%c %d %d %f %s \n", ch, i, pi, pf, p); } void fun2(char ch, ...) { int i, pi; float pf; char p; va_list list; printf("%c ", ch); va_start(list, ch); i = va_arg(list, int); printf("%d ", i); pi = va_arg(list, int); printf("%d ", pi); pf = va_arg(list, float); printf("%f ", pf); p = va_arg(list, char ); printf("%s", p); }....
MCQ->If the size of pointer is 4 bytes then What will be the output of the program ? #include<stdio.h> int main() { char str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"}; printf("%d, %d", sizeof(str), strlen(str[0])); return 0; }....
MCQ->What will be the output of the following program? #include<iostream.h> #include<string.h> class IndiaBix { char str[50]; char tmp[50]; public: IndiaBix(char s) { strcpy(str, s); } int BixFunction() { int i = 0, j = 0; while((str + i)) { if((str + i++) == ' ') (tmp + j++) = (str + i); } (tmp + j) = 0; return strlen(tmp); } }; int main() { char txt[] = "Welcome to IndiaBix.com!"; IndiaBix objBix(txt); cout<< objBix.BixFunction(); return 0; }....
MCQ->Which of the following statement is correct about the program given below? #include<iostream.h> class IndiaBix { int x; float y; public: void BixFunction(int = 0, float = 0.00f, char = 'A'); void BixFunction(float, int = 10.00, char = 'Z'); void BixFunction(char, char, char); }; int main() { IndiaBix objBix; objBix.BixFunction(10 1.0, int(56.0)); return 0; } void IndiaBix::BixFunction(int xx, float yy, char zz) { x = xx + int(yy); cout<< "x = " << x << endl; } void IndiaBix::BixFunction(float xx, int yy, char zz) { x = zz + zz; y = xx + yy; cout<< " x = " << x << endl; } void IndiaBix::BixFunction(char xx, char yy, char zz) { x = xx + yy + zz; y = float(xx 2); cout<< " x = " << x << endl; }....
MCQ->What will be the output of the following program? #include<iostream.h> #include<string.h> class IndiaBix { char txtMsg[50]; public: IndiaBix(char str = NULL) { if(str != NULL) strcpy(txtMsg, str); } int BixFunction(char ch); }; int IndiaBix::BixFunction(char ch) { static int i = 0; if(txtMsg[i++] == ch) return strlen((txtMsg + i)) - i; else return BixFunction(ch); } int main() { IndiaBix objBix("Welcome to IndiaBix.com!"); cout<< objBix.BixFunction('t'); return 0; }....
Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution