Peter Vegas wrote a new blog post: How to redirect page using PHP with values? 1 year, 4 months ago
Here is the code for simple PHP page redirect. The search engine friendly way of redirecting is the 301 redirect. Note that if you do not include the first Header line above, the redirect still works. But, instead of a 301 redirect, now it becomes a 302 (temporary) redirect. Now if you want to redirect [...]
Peter Vegas wrote a new blog post: 85. Predict the output or error(s) of the following c code 1 year, 7 months ago
main() { int i =0;j=0; if(i && j++) printf(“%d..%d”,i++,j); printf(“%d..%d,i,j); } Click here to view the answer Answer: 0..0 Explanation: The value of i is 0. Since this information is enough to determine the truth value of the boolean expression. So the statement following the if statement is not executed. The values of i and j remain…[Read more]
Peter Vegas wrote a new blog post: 84. Predict the output or error(s) of the following c code 1 year, 7 months ago
#include “stdio.h”
main()
{
FILE *ptr;
char i;
ptr=fopen(“zzz.c”,”r”);
while((i=fgetch(ptr))!=EOF)
printf(“%c”,i);
}
Click here to view the answer
Answer:
contents of zzz.c followed by an infinite loop
Explanation:
The condition is checked against EOF, it should be checked against NULL.
Peter Vegas wrote a new blog post: 83. Predict the output or error(s) of the following c code 1 year, 7 months ago
#include “stdio.h” aaa() { printf(“hi”); } bbb(){ printf(“hello”); } ccc(){ printf(“bye”); } main() { int (*ptr)(); ptr=aaa; ptr=bbb; ptr=ccc; ptr(); } Click here to view the answer Answer: bye Explanation: ptr is array of pointers to functions of return type int.ptr is assigned to address of the function aaa. Similarly ptr and ptr for bbb and…[Read more]
Peter Vegas wrote a new blog post: 82. Predict the output or error(s) of the following c code 1 year, 7 months ago
#include “stdio.h”
int one_d[]={1,2,3};
main()
{
int *ptr;
ptr=one_d;
ptr+=3;
printf(“%d”,*ptr);
}
Click here to view the answer
Answer:
garbage value
Explanation:
ptr pointer is pointing to out of the array range of one_d.
Peter Vegas wrote a new blog post: 81. Predict the output or error(s) of the following c code 1 year, 7 months ago
main(int argc, char **argv)
{
printf(“enter the character”);
getchar();
sum(argv,argv);
}
sum(num1,num2)
int num1,num2;
{
return num1+num2;
}
Click here to view the answer
Answer:
Compiler error.
Explanation:
argv & argv are strings. They are passed to the function sum without converting it to integer values.
Peter Vegas wrote a new blog post: 80. Predict the output or error(s) of the following c code 1 year, 8 months ago
main()
{
char c=’ ‘,x,convert(z);
getc(c);
if((c>=’a') && (c< ='z'))
x=convert(c);
printf("%c",x);
}
convert(z)
{
return z-32;
}
Click here to view the answer
Answer:
Compiler error
Explanation:
declaration of convert and format of getc() are wrong.
Peter Vegas wrote a new blog post: 79. Predict the output or error(s) of the following c code 1 year, 8 months ago
main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf(“%p…%p…%p”,p,q,r);
}
Click here to view the answer
Answer:
0001…0002…0004
Explanation:
++ operator when applied to pointers increments address according to their corresponding data-types.
Peter Vegas wrote a new blog post: 78. Predict the output or error(s) of the following c code 1 year, 8 months ago
main()
{
int i=_l_abc(10);
printf(“%dn”,–i);
}
int _l_abc(int i)
{
return(i++);
}
Click here to view the answer
Answer:
9
Explanation:
return(i++) it will first return i and then increments. i.e. 10 will be returned.
Peter Vegas wrote a new blog post: 77. Predict the output or error(s) of the following c code 1 year, 8 months ago
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf(“origin is(%d%d)n”,(*pp).x,(*pp).y); printf(“origin is (%d%d)n”,pp->x,pp->y); } Click here to view the answer Answer: origin is(0,0) origin is(0,0) Explanation: pp is a pointer to structure. we can access the elements of the structure either with arrow mark or…[Read more]
Peter Vegas wrote a new blog post: 76. Predict the output or error(s) of the following c code 1 year, 8 months ago
struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main() { struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1;def.prev=&abc;def.next=&ghi; ghi.i=2;ghi.prev=&def; ghi.next=&jkl; jkl.i=3;jkl.prev=&ghi;jkl.next=&abc; x=abc.next->next->prev->next->i; printf(“%d”,x); } Click here to view the answer Answer: 2…[Read more]
Peter Vegas wrote a new blog post: 74. Predict the output or error(s) of the following c code 1 year, 8 months ago
main()
{
int i=5,j=6,z;
printf(“%d”,i+++j);
}
Click here to view the answer
Answer:
11
Explanation:
the expression i+++j is treated as (i++ + j)
Peter Vegas wrote a new blog post: 73. Predict the output or error(s) of the following c code 1 year, 8 months ago
#include “stdio.h” main() { register i=5; char j[]= “hello”; printf(“%s %d”,j,i); } Click here to view the answer Answer: hello 5 Explanation: if you declare i as register compiler will treat it as ordinary integer and it will take integer value. i value may be stored either in register or in memory. [...]
Peter Vegas wrote a new blog post: 72. Predict the output or error(s) of the following c code 1 year, 8 months ago
#include “stdio.h” main() { int a = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a; *q=***a; printf(“%d..%d”,*p,*q); } Click here to view the answer Answer: garbagevalue..1 Explanation: p=&a you declare only two 2D arrays. but you are trying to access the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of…[Read more]
Peter Vegas wrote a new blog post: 71. Predict the output or error(s) of the following c code 1 year, 8 months ago
#include “stdio.h”
main()
{
const int i=4;
float j;
j = ++i;
printf(“%d %f”, i,++j);
}
Click here to view the answer
Answer:
Compiler error
Explanation:
i is a constant. you cannot change the value of constant
Peter Vegas wrote a new blog post: 70. Predict the output or error(s) of the following c code 1 year, 8 months ago
main() { int i=-1; -i; printf(“i = %d, -i = %d n”,i,-i); } Click here to view the answer Answer: i = -1, -i = 1 Explanation: -i is executed and this execution doesn’t affect the value of i. In printf first you just print the value of i. After that the value of the expression -i = [...]
Peter Vegas wrote a new blog post: 69. Predict the output or error(s) of the following c code 1 year, 8 months ago
main() { int *j; { int i=10; j=&i; } printf(“%d”,*j); } Click here to view the answer Answer: 10 Explanation: The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main function. Since the i [...]
Peter Vegas wrote a new blog post: 68. Predict the output or error(s) of the following c code 1 year, 8 months ago
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf(“%d”,i); } printf(“%d”,i); } printf(“%d”,i); } Click here to view the answer Answer: 30,20,10 Explanation: ‘{‘ introduces new block and thus new scope. In the innermost block i is declared as, const volatile unsigned which is a valid declaration. i is assumed of [...]
Peter Vegas wrote a new blog post: 67. Predict the output or error(s) of the following c code 1 year, 8 months ago
#define max 5 #define int arr1 main() { typedef char arr2; arr1 list={0,1,2,3,4}; arr2 name=”name”; printf(“%d %s”,list,name); } Click here to view the answer Answer: Compiler error (in the line arr1 list = {0,1,2,3,4}) Explanation: arr2 is declared of type array of size 5 of characters. So it can be used to declare the variable name of the type [...]
Peter Vegas wrote a new blog post: 66. Predict the output or error(s) of the following c code 1 year, 8 months ago
main() { int y; scanf(“%d”,&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf(“%d is a leap year”); else printf(“%d is not a leap year”); } Click here to view the answer Answer: 2000 is a leap year Explanation: An ordinary program to check if leap year or not. [...]
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Resources #Terms of Use
Copyright©2012 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com