0% found this document useful (0 votes)
53 views

PSA Ques Objective

Uploaded by

inshasaife1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

PSA Ques Objective

Uploaded by

inshasaife1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 272

void main()

{
// size of int is 2 Bytes
int a=32768;
unsigned int b=65536;
printf("%d\n%d",a,b);
}
Output :

-32768
0
#include<stdio.h>
int main()
{
printf(“%d”, printf(“%s”,”Hello World!”));
return 0;
}
Out Put:-

Hello World!12
int main()
{
printf(“%10s”,”Hello”);
return 0;
}
Out Put:-
Hello
int main()
{
char ch = 255;
ch = ch + 10;
printf(“%d”,ch);
return 0;
}
Out Put:-

9
Which of the Following is correct.

1. signed int I;
2. signed I;
3. unsigned I;
4. long l;
5. long int I;
6. long long I;
int main() {
int var = 052;
printf(“%d”,var);
return 0;
}
Out Put:- 42
int main() {
int var = 052;
printf(“%o”,var);
return 0;
}
Out Put:- 52
int main() {
int var = 0x43FF;
printf(“%x”,var);
return 0;

int main() {
int var = 0x43FF;
printf(“%X”,var);
return 0;

}
void main()
{
char a=128;
unsigned char b=256;
printf("%d \n %d",a,b);
}
Output :

-128
0
void main()
{
printf("%d%d%d%d",6/5,-6/5,6/-5,-6/-5);

}
Output:-

1-1-11
void main()
{
printf("%d%d%d%d",6%5,-6%5,6%-5,-6%-5);
}
Output:-
1-11-1

Explanation : If we have negative numbers, the result will be


based on the left operand's sign, if the left operand is positive –
the result will be positive, and if the left operand is negative –
the result will be negative.
Thus, in the result (remainder), the sign of left operand is
appended.
void main()
{
int a=23,b=12,c=10,d;
d=c+2=b+1=a;
printf("%d%d%d%d",a,b,c,d);
}
Output:-

Error(Code Not Compile)


void main()
{
int a=2,b=3,c=1,d;
d=a<b>c;
printf("%d",d);
}
Output:- Move from Left to Right

0
void main()
{
int a=2,b=3,c=1,d;
d=a<b<c-1;
printf("%d",d);
}
Output:-

0
void main()
{
int a=10,b=20,c=30;
c=a==b;
printf("%d%d%d",a,b,c);
}
Output:- If Condition is true then print 1 else
print 0.

10 20 0
void main() {
int a=012,b=034;
int x=0x12,y=0x34;
int c,d,u,v;
c=a&b;
d=a|b;
u=x&y;
v=x|y;
printf("%d\t%d\t%d\t%d",c,d,u,v);
}
Output:-

8 30 16 54
void main() {
int a=012,b=034;
int x=0x12,y=0x34;
int c,d,u,v;
c=a&&b;
d=a||b;
u=x&&y;
v=x||y;
printf("%d\t%d\t%d\t%d",c,d,u,v);
}
Output:-

1 1 1 1
void main()
{
int c=10,d,e;
d=!c;
e=~c;
printf("%d\t%d",d,e);
}
Output:-

0 -11
void main()
{
int i=10,j=11,k,l;
k=i++ + j;
l=i++ + ++j;
printf("%d\t%d",l,k);
}
Output:-

23 21
void main()
{
int i=10,j=11,k,l;
k=i + ++j;
l=i++ + ++j;
printf("%d\t%d",l,k);
}
Output:-

23 22
void main()
{
int x=32767;
printf("%d",x<<1);
}
Output:-

65534
void main() {
float u=3.5;
int v,w,x,y;
v=(int)(u+0.5);
w=(int)u+0.5;
x=(int)((int)u+0.5);
y=(u+(int)0.5);
printf("%d\t%d\t%d\t%d",v,w,x,y);
}
Output:-

4 3 3 3
void main()
{
printf("value is = %d",(10++));
}
Error : L-value required

++/-- operator works on variables only.


void main()
{
const char var='A';
++var;
printf("%c",var);
}
Error : increment of read-only variable 'var'.

++/-- operator works on variables only, we can


not change the value of a const.
void main()
{
short var=‘A';
var+=2;
var++;
printf("var : %c , %d ", var,var);
}
Output :
var : D , 68
int main(){
float a;
(int)a= 10;
printf("value of a=%d",a);
return 0;
}
Output :
Error: L-value required.
(int)a will return an integer constant value and 10 is also an
integer value, and constant value can not assign in constant
value.
int main(){
int x;
x=100,30,50;
printf("x=%d\n",x);
x=(100,30,50);
printf("x=%d\n",x);
return 0;
}
Output :
x=100
x=50
Since = (assignment operator) has more precedence than
comma operator (,), so = operator evaluates first and 100 will be
assigned to x.
In second case, x=(100,30,50), here () have more precedency
so (100,30,50) will be evaluated first from left to right, and x will
be 50.
int main(){
int var;
var=- -10;
printf("value of var= %d\n",var);
var=+ +10;
printf("value of var= %d\n",var);
return 0;
}
Output :
value of var= 10
value of var= 10

Here unary minus (or negation) operator is used twice.


According to the math rules:
- -10 = 10
+ +10=10
int main()
{
int var = 010;
printf("%d", var);
}
Output :
8

Explanation: 010 is octal representation of 8.


void main()
{
float a=125.50;
int b=125.50;
char c='A';

printf("%d,%d,%d\n",sizeof(a),sizeof(b),sizeof(125.50));
printf("%d,%d\n",sizeof(c),sizeof(65));
}
Output :
4,4,8
1,4
int main()
{
short int i = 20;
char c = 97;
printf("%d, %d, %d\n", sizeof(i), sizeof(c),
sizeof(c + i));
return 0;
}
Output :
2, 1, 4
void main()
{
char a = 'a';
int x = (a % 10)++;
printf("%d\n", x);
}
Error : L-value required

++/-- operator works on variables only.


void main()
{
int ok=-100;
-100;
printf("%d",ok);
}
Output :
-100

-100 is evaluated and this does not effect the


value of ok.
void main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d\n", y);
}
Output :
2
void main()
{
int k = 7;
int m = 8;
int z = k < m ? k = m : m++;
printf("%d", z);
}
Output :
8
int main()
{
int a=10,b=20;
if(a==b)
printf("a=10,b=20");
printf("a and b are not equal");
}
Output :
a and b are not equal
int main()
{
int a=10,b=20;
if(a=b)
printf("a and b are equal");
else
printf("a and b are not equal");

}
➢Output :

a and b are equal


int a=10,b=20;
if(a==b);
printf("a and b are equal");
else
printf("a and b are not equal");
Output :
Error : 'else' without a previous 'if'
void main()
{
if(1)
printf("This will always get executed");
else
printf("This will never get executed");

}
Output :
This will always get executed
void main()
{
if(printf("Hello"))
printf("Students");

}
Output :
HelloStudents
void main()
{
if(!printf(""))
printf("Okkk");
else
printf("Hiii");
}
Output :
Okkk
void main()
{
char val=1;
if(val--==0)
printf("TRUE");
else
printf("FALSE");
}
Output :
FALSE
void main()
{
int a=10;
if(a==10)
{
printf("Hello...");
break;
printf("Ok");
}
else
{
printf("Hii");
} }
Output :
Error : misplaced break/ illegal break
A break statement can be used with looping and
switch statements.
int main()
{
if( (-100 && 100)||(20 && -20) )
printf("%s","Condition is true.");
else
printf("%s","Condition is false.");
return 0;
}
Output :
Condition is true.
Any non zero value is treated as true for
conidion.
void main()
{ int TRUE=1;
if(TRUE)
printf("1");
printf("2");
else
printf("3");
printf("4");
}
Output :
[Error] 'else' without a previous 'if'
void main()
{
int a=100;
if(a>20)
if(a<20)
printf("Hello");
else
printf(“Bye");
}
Output :
Bye
void main()
{
int expr=10;
switch(expr)
printf("This is valid but will not get
executed");
}
Output :
No output
void main()
{
float expr=2.0;
switch(expr)
{
case 1:printf("One");
case 2:printf("Two");
default:printf("default");
}

}
Output :
Error : switch quantity not an integer
void main()
{
int expr=2,j=1;
switch(expr)
{
case j:
printf("This is case 1");
case 2:
printf("This is case 2");
default:
printf("This is default case"); }}
Output :
[Error] case label does not reduce to an integer
constant
void main()
{ char ch='A';
switch(ch)
{
case 'A':
printf("Case label is A");
case "B":
printf("Case label is B");
}
}
Output :
[Error] case label does not reduce to an integer
constant
void main()
{
int expr=1;
switch(expr)
{
case 1:printf("One\n");
case 2:printf("Two\n");
default:printf("Three\n");
}
}
Output :
One
Two
Three
void main()
{
int expr=3;
switch(expr)
{
default:printf("Three\n");
case 1:printf("One\n");
case 2:printf("Two\n");
}
}
Output :
Three
One
Two
void main()
{ int expr=2;
switch(expr)
{
case 1:
printf("This is case 1");
case 2-1:
printf("This is case 2");
}
}
Output :
[Error] duplicate case value
[Error] previously used here
void main()
{
int i=1,j=3;
switch(i)
{
case 1:
printf("This is outer case 1\n");
switch(j)
{
case 3:
printf("This is inner case 1\n");
break;
default:
printf("This in inner default case");
}
case 2:
printf("This is outer case 2");
}
}
Output :
This is outer case 1
This is inner case 1
This is outer case 2
void main()
{
int expr=2;
switch(expr)
{
case 1:
printf("This is case 1");
break;
case 2:
printf("This is case 2");
continue;
default:
printf("Default");
}

}
Output :
[Error] continue statement not within a loop
void main()
{
int i=1;
loop:
printf("%d",i++);
if(i==5)
break;
goto jump;

}
Output :
[Error] break statement not within loop or
switch.
[Error] label 'jump' used but not defined
void main()
{
short day=2;
switch(day)
{
case 2: || case 22:
printf("%d nd",day);
break;
default:
printf("%d th",day);
break;
}
}
Output :
Syntax Error
We can not use || operator between case
statements, case 2:||case 22: invalid
void main()
{
int x;
float y=7.0;
switch(x=y+1)
{
case 8: printf("It's Eight."); break;
default: printf("Oops No choice here!!!");
}
}
Output :
It's Eight.
Here, x=y+1 will be 8 , because x is an integer
variable so final value that will return through
this expression is 8.
void main()
{
int i=1;
loop:
printf("%d",i++);
if(i==5)
goto out;
goto loop;
out:
;
}
Output :
1234
main()
{
int i= 3;
goto label;
for(i=0;i<5;i++)
{
label:
printf("%d",i);
}
}
Output :
34
main()
{
int i=1;
while(i<=5)
printf("%d",i);
printf("The value of i after the loop is %d",i);
}
Output:-

1 infinite times
void main()
{
int n=0,a=5,b=10;
while(n<=(a^b))
{
n++;
}
printf("%d",n);
}
Output :
16
void main()
{
int a=16,n=0;
while(n<=~(~a))
{
n++;
}
a=n;
printf("%d",~a);
}
Output :
-18
main()
{
int i=1;
for( )
{
printf("%d",i);
if(i=5)
break;
}
}
Output:-

[Error] expected expression before ')' token


[Error] expected expression before ')' token
void main()
{
int i;
for(i=1;i<=32767;i++)
printf("%d",i);
}
Output:-

1 To 32767
void main()
{
int i=1;
for(;;)
{
printf("%d",i);
if(i==5)
break;
}
}
Output:-

1 infinite times
void main()
{
int i=1;
for(;;)
{
printf("%d",i);
if(i=5)
break;
}
}
Output:-

1
void main()
{
int i=1;
for(;i<=5;printf("%d",i++));
}
Output:-

12345
void main()
{
int i=1;
for(;i<=10;i++)
{
if(i%2==0)
continue;
printf("%d",i);
}
}
Output:-

13579
void main()
{
int i,j;
for(i=1;i<3;i++)
for(j=1;j<4;j++)
{
if(i==2)break;
printf("%d%d\n",i,j);
}
}
Output:-

11
12
13
void main()
{
int i,j;
for(i=1;i<3;i++)
for(j=1;j<4;j++)
{
if(i==2)continue;
printf("%d%d\n",i,j);
}
}
Output:-

11
12
13
void main()
{
int i=0;
for(;++i;)
printf("%d",i);
}
Output:-

1234…….up to infinite
void main()
{
int i=0;
for(;i++;)
printf("%d",i);
}
Output:-

Nothing is printed
void main()
{
int i=3,j=3;
for(;i<6,j<4;i++,j++)
printf("%d%d\n",i,j);
}
Output:-

33
void main()
{
int i=5;
do
{
printf("%d",i);
i++;
}while(i<10);
}
Output:-

56789
void main()
{
int i=5;
do
{
printf("%d",i);
i++;
}while(i<0);
}
Output:-

5
int main()
{
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
Output:-

1
int main()
{
int i,j;
i=j=2,3;
while(--i&&j++)
printf("%d %d",i,j);
return 0;
}
Output:-

1 3
int main()
{
int i;
for(i=0;i<=5;i++);
printf("%d",i);
return 0;
}
Output:-

6
int main()
{
char c=125;
do
printf("%d ",c);
while(c++);
return 0;
}
Output:-

125 126 127 -128 -127 ……….0


int main()
{
int x=123;
int i={
printf("c" "++")
};
for(x=0;x<=i;x++) {
printf("%d ",x);
}
return 0; }
Output:-

C++ 0 1 2 3
int main(){
int m=10;
int x=printf("%d ",m);
printf("%d",x);
return 0;
}
Output:-

10 3

printf() returns total number of printed


characters, the statement int x=printf("%d ",m)
will print 10 (10 and one space) and return 3.
Thus output will be 10 3 [10<space>3].
int main(){
int x='A';
printf("%02X",x);
return 0;
}
Output:-

41

Statement int x='A'; will declare x as integer and


assign the ASCII value of 'A' (that is 65) in it. And
the statement printf("%02X",x); will print the
ASCII value (65) in the 2 bytes Hexadecimal
forma (that is 41). Thus output will be 41.
int main()
{
int a=1,b=2,c=3;
printf("%d %d %d");
return 0;
}
Output:-

Gargabe value
void main()
{
int a;
a=printf("Hello")+printf("Readers!!");
printf("\n%d characters printed",a);
}
Output:-

HelloReaders!!
14 characters printed
void main()
{
int a=10,b=20,c;
c=add(a,b);
printf("The result after addition is %d",c);
}
int add(int a,int b)
{
return a+b;
}
Output:-

The result after addition is 30


int main()
{
int n=0;
while(n<printf("MENU\n"))
{
n++;
}
return 0;
}
Output:-

6 times MENU
#include<stdio.h>

main()
{
int const a = 5;

a++;
printf(“%d”,a);
}
Ans:- Compile error
#include<stdio.h>

main()
{
const int a = 5;

a++;
printf("%d", a);
}
Ans:- Compile error
#include<stdio.h>

main()
{
char s[]="hello", t[]="hello";

if(s==t){
printf("eqaul strings");
}
}
Ans:- No output
#include<stdio.h>
main()
{
int a = 1;
float b = 1.3;
double c;
c = a + b;
printf("%.2lf", c);
}
Ans:- 2.30
#include<stdio.h>

main()
{
char c = 'A'+256;

printf("%c", c);
}
Ans:- A
main()
{
int x = 5;

if(x==5)
{
if(x==5) break;
printf("Hello");
}
printf("Hi");
}
Ans:- Compile error
#include<stdio.h>

main()
{
int x = 5;

if(x=5)
{
if(x=5) break;
printf("Hello");
}
printf("Hi");
}
Ans:- Compile error
#include<stdio.h>

main()
{
int x = 5;

if(x=5)
{
if(x=5) printf("Hello");
}
printf("Hi");
}
Ans:- HelloHi
#include<stdio.h>

main()
{
for(1;2;3)
printf("Hello");
}
Ans:- Infinite loop
#include<stdio.h>

void f()
{
static int i;

++i;
printf("%d", i);
}

main()
{
f();
f();
f();
}
Ans:- 1 , 2 , 3
• What is right way to Initialize array?

A. int num[6] = { 2, 4, 12, 5, 45, 5 };


B. int n{} = { 2, 4, 12, 5, 45, 5 };
C. int n{6} = { 2, 4, 12 };
D. int n(6) = { 2, 4, 12, 5, 45, 5 };
Ans :- A
What will be the output of the program ?
#include <stdio.h>
void main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
}
A. 3, 2, 15
B. 2, 1, 15
C. 1, 2, 5
D. 2, 3, 20
Ans:- A
What will be the output of following program code?
#include <stdio.h>
int main(void) {
char p;
char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};
p = (buf + 1)[5];
printf("%d", p);
return 0;
}
A. 9
B. 6
C. 5
D. Error
Ans:- A
Ans:- A
int main()
{
int arr[5];
arr++;
printf("%u", arr);

return 0;
}
Answer: Compile Time Error

Explanation: Array name in C is implemented by


a constant pointer. It is not possible to apply
increment and decrement on constant types.
#include <stdio.h>
int main()
{
int arr[5];
// Assume base address of arr is 2000 and size
//of integer is 32 bit
printf("%u %u", arr + 1, &arr + 1); //

return 0;
}
Answer: 2004 , 2020
Name of array in C gives the address(except in sizeof operator) of the first
element. Adding 1 to this address gives the address plus the sizeof type the
array has. Applying the Address-of operator before the array name gives the
address of the whole array. Adding 1 to this address gives the address plus
the sizeof whole array.
void print(int arr[])
{
int n = sizeof(arr)/sizeof(arr[0]);
int i;
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
}

int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
print(arr);
return 0;
}
Answer:
According to 32 bit compiler : 1
According to 64 bit compiler : 1, 2
int main()
{
int i;
int arr[5] = {1};
for (i = 0; i < 5; i++)
printf("%d ", arr[i]);
return 0;
}
Answer: 1 0 0 0 0
int main()
{
int i;
int arr[5] = {0};
for (i = 0; i <= 5; i++)
printf("%d ", arr[i]);
return 0;
}
0 0 0 0 0 GV
# include <stdio.h>
int main()
{
char str1[] = "HelloQuiz";
char str2[] = {'H', 'e', 'l', 'l', 'o', 'Q', 'u', 'i', 'z'};
int n1 = sizeof(str1)/sizeof(str1[0]);
int n2 = sizeof(str2)/sizeof(str2[0]);
printf("n1 = %d, n2 = %d", n1, n2);
return 0;
}
The size of str1 is 10 and size of str2 9.

When an array is initialized with string in double


quotes, compiler adds a ‘\0’ at the end.
#include<stdio.h>
int main()
{
char str[] = "HelloQuiz";
printf("%s %s %s \n", &str[5], &5[str], str+5);
printf("%c %c %c ", *(str+6), str[6], 6[str]);
return 0;
}
Quiz Quiz Quiz u u u
In below program, what would you put in place
of “?” to print “Quiz”?

#include <stdio.h>
int main()
{
char arr[] = “HelloQuiz";
printf("%s", ?);
return 0;
}
Answer: (arr+5)

Since %s is used, the printf statement will print


everything starting from arr+5 until it finds ‘\\0’
#include <stdio.h>

int main()
{
int a[][] = {{1,2},{3,4}};
int i, j;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
printf("%d ", a[i][j]);
return 0;
}
Compile Time Error
void fun(int n)
{
int idx;
int arr1[n] = {0};
int arr2[n];

for (idx=0; idx<n; idx++)


arr2[idx] = 0;
}

int main()
{
fun(4);
return 0;
}
Compile time error.

There’s no issue with definition of arr1 and arr2. In definition of these arrays,
the mention of array size using variable is ok as per C standard but these
types of arrays can’t be initialized at the time of definition. That’s why
initialization of arr1 is incorrect. But initialization of arr2 is done correctly
int size = 4;
int arr[size];

int main()
{
if(arr[0])
printf("Initialized to ZERO");
else
printf("Not initialized to ZERO");

return 0;
}
Compile Time Error
# include <stdio.h>
int main ()
{
char a [6] = "world";
int i, j;
for (i = 0, j = 5; i < j; a [i++] = a [j--])
printf ("%s", a);
}
# include <stdio.h>
int main ()
{
char a [6] = "world";
int i, j;
for (i = 0, j = 5; i < j; a [i++] = a [j--]);
printf ("%s", a);
}
No Out Put
#include <stdio.h>
int main()
{
char str[] = "%d %c", arr[] = "HelloQuiz";
printf(str, 0[arr], 2[arr + 3]);
return 0;
}
72 Q
#include<stdio.h>
int main()
{
char str[20] = "HelloQuiz";
printf ("%d", sizeof(str));
return 0;
}
20
#include <stdio.h>
int main()
{
char *str1 = "GeeksQuiz";
char str2[] = "GeeksQuiz";

printf("sizeof(str1) = %d, sizeof(str2) = %d",


sizeof(str1), sizeof(str2));

return 0;
}
32 bit : 4 10
64 bit : 8 10
#include <stdio.h>
int main ()
{
int i, j;
int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
for(i = 0; i < 3; i++) {
a[i] = a[i] + 1;
i++;
}
i--;
for (j = 7; j > 4; j--) {
int i = j/2;
a[i] = a[i] - 1;
}
printf ("%d, %d", i, a[i]);
}
3,2
#include <stdio.h>
int main()
{
printf("%d", main);
return 0;
}
Explanation: Name of the function is actually a pointer variable to the
function and prints the address of the function. Symbol table is implemented
like this.
int main()
{
int i;
char s[]= "hello";
for(i=0; s[i]; ++i)
printf("%d ",i);

i=0;
printf("\n");
while(s[i++]);
printf("%d ",i);
}
01234
6
int main()
{
char ch[50],ch1[50]="hello";

ch = ch1;
printf("%s",ch);

}
Compile Time Error
int main()
{
char *s = "Abc";

while(*s)
printf("%c",*s++);

}
Abc
int main()
{
char s[] = "Fine";

*s = 'N';
printf("%s",s);

}
Nine
int main()
{
int arr[] = {10,20,30};

printf("%d",*arr+1);

}
11
void dynamic(int s, ...)
{
printf("%d ", s);
}

int main()
{
dynamic(2, 4, 6, 8);
dynamic(3, 6, 9);
return 0;
}
In c three continuous dots is known as ellipsis which is variable
number of arguments of function. The values to parameters are
assigned one by one
int fun()
{
static int num = 16;
return num--;
}

int main()
{
for(fun(); fun(); fun())
printf("%d ", fun());
return 0;
}
14 11 8 5 2
void fun(int x)
{
x = 30;
}

int main()
{
int y = 20;
fun(y);
printf("%d", y);
return 0;
}
20
void fun(int *x)
{
*x = 30;
}

int main()
{
int y = 20;
fun(&y);
printf("%d", y);
return 0;
}
30
int main()
{
int *ptr;
int x;

ptr = &x;
*ptr = 0;

printf(" x = %d\n", x);


printf(" *ptr = %d\n", *ptr);
return 0;
}
0 0
int main()
{
int *ptr;
int x;

ptr = &x;
*ptr = 0;
*ptr += 5;
printf(" x = %d\n", x);
printf(" *ptr = %d\n", *ptr);

Return 0;
}
5 5
int main()
{
int *ptr;
int x;
ptr = &x;
*ptr = 0;

*ptr += 5;
(*ptr)++;
printf(" x = %d\n", x);
printf(" *ptr = %d\n", *ptr);
return 0;
}
6 6
int main()
{
int arri[] = {1, 2 ,3};
int *ptri = arri;

char arrc[] = {1, 2 ,3};


char *ptrc = arrc;

printf("sizeof arri[] = %d\n ", sizeof(arri));


printf("sizeof ptri = %d\n ", sizeof(ptri));

printf("sizeof arrc[] = %d\n ", sizeof(arrc));


printf("sizeof ptrc = %d\n ", sizeof(ptrc));

return 0;
}
12
8
3
8
#include<stdio.h>
int main()
{
int arr[] = {10, 20, 30, 40, 50, 60};
int *ptr1 = arr;
int *ptr2 = arr + 5;
printf("Number of elements between two pointer are: %d.\n",
(ptr2 - ptr1));
printf("Number of bytes between two pointers are: %d\n",
(char*)ptr2 - (char*) ptr1);
return 0;
}
5
20
void fun(int arr[])
{
int i;
int arr_size = sizeof(arr)/sizeof(arr[0]);
for (i = 0; i < arr_size; i++)
printf("%d ", arr[i]);
}

int main()
{
int i;
int arr[4] = {10, 20 ,30, 40};
fun(arr);
return 0;
}
10 , 20
#include<stdio.h>

main()
{
int *p = 15;
printf("%d",*p);
}
Ans:- Runtime error
#include<stdio.h>

main()
{
register int x = 5;

int *p;
p=&x;
x++;
printf("%d",*p);
Ans:- Compile error
#include<stdio.h>

main()
{
int x = 65, *p = &x;

void *q=p;
char *r=q;
printf("%c",*r);
}
Ans:- 65
Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy