<< < 21 22 23 24 25 26 27 >   Sort: Rank

Variable Types
What are the types of variables x, y, y and u defined in the following code? #define Atype int* typedef int *p; p x, z; Atype y, u; Answer: x and z are pointers to int. y is a pointer to int but u is just an integer variable
2007-02-26, 6265👍, 0💬

Conditional Statements
What will happen in these three cases? if (a=0) { //somecode } if (a==0) { //do something } if (a===0) { //do something }
2007-02-26, 6390👍, 0💬

Shift Operations
What will the following piece of code do? int f(unsigned int x) { int i; for (i=0; x!=0; x&gt;&gt;1) { if (x &amp; 0x1) i++; } return i; } Answer: returns the number of ones in the input parameter X.
2007-02-26, 6281👍, 0💬

Conditional Statements
What will be printed as the result of the operation below: main() { int a=0; if (a==0) printf("Cisco Systems\n"); printf("Cisco Systems\n"); } Answer: Two lines with "Cisco Systems" will be printed.
2007-02-26, 6509👍, 0💬

Incremental Operatiors
What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y; printf("%d %d\n",x,y); } Answer: 11, 16
2007-02-26, 6595👍, 0💬

Function Calls
What will be printed as the resultof the operation below: int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyva...
2007-02-26, 6543👍, 0💬

Constants
WHat will be the result of the following code? #define TRUE 0 // some code while (TRUE) { // some code } Answer: This will not go into the loop as TRUE is defined as 0.
2007-02-26, 6737👍, 0💬

Static Variables
The following variable is available in file1.c, who can access it? static int average; Answer: all the functions in the file1.c can access the variable.
2007-02-26, 7155👍, 0💬

String Concatenation
What will be printed as the result of the operation below: main() { char *p1; char *p2; p1=(char *)malloc(25); p2=(char *)malloc(25); strcpy(p1,"Cisco"); strcpy(p2,"systems"); strcat(p1,p2); printf("%s",p1); } Answer: Ciscosystems
2007-02-26, 7195👍, 0💬

Character Array
What will be printed as the result of the operation below: main() { char s1[]="Cisco"; char s2[]="systems"; printf("%s",s1); } Answer: Cisco
2007-02-26, 7875👍, 0💬

String Pointers
What will be printed as the result of the operation below: main() { char *ptr = " Cisco Systems"; *ptr++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } 1) ptr++ increments the ptr address to point to the next address. In the prev example, ptr was pointing to the space in the string before C, now ...
2007-02-26, 10417👍, 0💬

Function Calls
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void main() { int x=5, y=10; swap (x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a, int b) { int temp; temp=a; b=a; a=temp; return 0; } The correct answer is 10, 5 5, 10
2007-02-26, 6536👍, 0💬

Shift Operators
What will be printed as the result of the operation below: main() { int x=5; printf("%d,%d,%d\n",x,x&lt ;&lt;2,x&gt;&gt;2) ;} As x = 5 = 0x0000,0101; so x &lt;&lt; 2 -&lt; 0x0001,0100 = 20; x &gt;&gt; 2 -&gt; 0x0000,0001 = 1. Therefore, the answer is 5, 20, 1.
2007-02-26, 6922👍, 0💬

Incremental Operatos
What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf("%d%d\n",x,y); } Answer : 5794
2007-02-26, 6586👍, 0💬

Using Pointers
What print out will the folloging code produce? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf(“%s\n”,p2);> } The pointer p2 value is also increasing with p1 . *p2++ = *p1++ means copy value of *p1 to *p2 , then increment both addresses (p...
2007-02-26, 6494👍, 0💬

Printing Permutaions of a String
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. void PrintPermu (char *sBegin, char* sRest) { int iLoop; char cTmp; char cFLetter[1]; char *sNewBegin; char *sCur; int iLen; static int iCount; iLen = strlen(sRest); i...
2007-02-26, 7209👍, 0💬

"union" Data Type
What's the output of the following program? And why? #include main() { typedef union { int a; char b[10]; float c; } Union; Union x,y = {100}; x.a = 50; strcpy(x.b,"hello"); x.c = 21.50; printf("Union x : %d %s %f n",x.a,x.b,x.c); printf("Union y : %d %s %f n",y.a,y.b,y.c); }
2007-02-26, 7519👍, 0💬

Deteting Circular Linked List
Can you tell me how to check whether a linked list is circular? Create two pointers, and set both to the start of the list. Update each as follows: while (pointer1) { pointer1 = pointer1-&gt;next; pointer2 = pointer2-&gt;next; if (pointer2) pointer2=pointer2-&gt;next ;if (pointer1 == poi...
2007-02-26, 7646👍, 0💬

Reducing the Final Size of an Executable File
How to reduce the final size of an executable file? Size of the final execuatable can be reduced using dynamic linking for libraries.
2007-02-26, 7655👍, 0💬

printf() and sprint() Functions
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the charecter array whereas printf(...) writes data to the standard output device.
2007-02-26, 17575👍, 0💬

calloc() and malloc() Functions
What is the difference between "calloc(...)" and "malloc(...)"? 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * size). malloc(...) takes in only a singl...
2007-02-26, 7979👍, 0💬

printf() Function
What is the output of printf("%d")? 1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after "%d", so compiler will show in output window gurbage value. 2. When we use %d the compiler internally uses it to access the argument in the stack (a...
2007-02-26, 7942👍, 0💬

What Is C Language
What Is C Language? The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C...
2007-02-26, 7221👍, 0💬

Tag &lt;?= ... ?&gt; in PHP
What does a special set of tags &lt;?= and ?&gt; do in a PHP script page? &lt;?= expression ?&gt; allows you to output the value of the specified expression into the HTML document directly.
2006-09-01, 8262👍, 0💬

<< < 21 22 23 24 25 26 27 >   Sort: Rank