C
Programming and Technical
Programming
Program
What will be the output of the program ?
#include
int main()
{
int i=3, *j, k;
j = &i;
printf("%dn", i**j*i+*j);
return 0;
}
Options
1) 30
2) 27
3) 9
4) 3
Read Solution (Total 9)
-
- i**j*i+*j means 3*(value of ponter j that is 3)*3+(value at pointer j which is again 3)
so the result is 3*3*3+3
30 - 9 years agoHelpfull: Yes(4) No(1)
- ans is not in the given option.
exactly the ans is 30n.
3*3*3+3=30 and also it print the 'n'.
printf("%dn", i**j*i+*j); - 9 years agoHelpfull: Yes(2) No(0)
- 1) 30
because i=3 and *j=3 - 9 years agoHelpfull: Yes(0) No(0)
- The actual result is 3*3*3+3=30,
but in the question ans is 30n - 9 years agoHelpfull: Yes(0) No(0)
- 30, just assume *j as i because putting * infront of pointer makes use of value stored by that mem location
- 9 years agoHelpfull: Yes(0) No(0)
- Option-1
output:= 30;
because i=3;
*j=3;
(i)*(*j)*(i)+(*j)
3*3*3+3=30;
j stored address of variable i and *j stored the value of i (i.e. pointer concept ) - 7 years agoHelpfull: Yes(0) No(0)
- i * (*j) * i + (*j) = 3 * 3 * 3 + 3 = 27
- 6 years agoHelpfull: Yes(0) No(0)
- i**j*i+*j it means given i=3
3*(3)*3+3=30 - 5 years agoHelpfull: Yes(0) No(0)
- i**j*i+*j means that 3*3*3+3=27+3
- 5 years agoHelpfull: Yes(0) No(0)
C Other Question
What will be the output of the program?
#include
int main()
{
int i=0;
for(; i<=5; i++);
printf("%d", i);
return 0;
}
Optons
1) 0, 1, 2, 3, 4, 5
2) 5
3) 1, 2, 3, 4
4) 6
What will be the output of the program ?
#include
int main()
{
static char *s[] = {"black", "white", "pink", "violet"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
++p;
printf("%s", **p+1);
return 0;
}
Options
1) ink
2) ack
3) ite
4) let