Practice Pointers – What will be output of following c program?
int main()
{
char *name = "name";
change (name);
printf ("%s", name);
return 0;
}
change (char *name)
{
char *nm = "newname";
name = nm;
}
Practice Pointers – What will be output of following c program?
int main()
{
char *name = "name";
change (name);
printf ("%s", name);
return 0;
}
change (char *name)
{
char *nm = "newname";
name = nm;
}
Practice Pointers – Which are valid?
(i) pointers can be added.
(ii) pointers can be subtracted.
(iii) integers can be added to pointers.
Practice Pointers – Which of the choices is true for the mentioned declaration?
const char *p;
and
char * const p;
Choose one of them:
Practice Pointers – What will be the output of the following “C” program?
struct adr {
char *name;
char *city;
int zip;
};
struct adr *adradr;
Which are valid references?
Practice Pointers – p and q are pointers to the same type of data items.
Which of these are valid?
(i) *(p+q)
(ii) *(p-q)
(iii) *p – *q
Practice Pointers – The size of generic pointer in c is 2 __
Practice Pointers – What will be output of the following “c” code?
#include
void main() {
char *p;
p = "Hello";
printf("%c", *&*p);
}
Practice Pointers – What will be output of the following “c” code?
#include
int main(){
int i;
static double *p,*q,*r,*s,t=5.0;
double **arr[]={&p,&q,&r,&s};
*p=*q=*r=*s=t;
for(i=0;i<4;i++)
printf("%.0f ",**arr[i]);
return 0;
}
What will be the output of the program on GCC compiler?
Practice Pointers –
What will be the output of the program on GCC compiler?
#include <stdio.h>
void fun(int*, int*);
int main() {
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *a, int *b) {
*a = *a * *a;
*b = *b * *b;
}
What will be the output of the folowing program on GCC compiler?
Practice Pointers –
What will be the output of the folowing program on GCC compiler?
#include<stdio.h>
#include<string.h>
int main() {
char *s;
char *fun();
s = fun();
printf("%s
", s);
return 0;
}
char *fun() {
char buffer[30];
strcpy(buffer, "RAM");
return (buffer);
}
Point out the error in the following program( on GCC compil
Practice Pointers –
Point out the error in the following program( on GCC compiler).
#include<stdio.h>
#include<stdlib.h>
int main() {
static char *p = (char *)malloc(10);
return 0;
}
What will be the output of the following program on GCC?
Practice Pointers –
What will be the output of the following program on GCC?
#include <stdio.h>
#include <malloc.h>
int main(){
struct node{
struct node *pre;
struct node *next;
int i;
};
struct node *p,*q;
p=(struct node *) malloc(sizeof (struct node));
q=(struct node *) malloc(sizeof (struct node));
p->i=75;
q->i=90;
p->pre=NULL;
p->next=q;
q->pre=p;
q->next=NULL;
while(p!=NULL){
printf("%d
", p->i);
p=p->next;
}
return 0;
}
What will be the output of the following program on GCC?
Practice Pointers –
What will be the output of the following program on GCC?
#include <stdio.h>
#include <malloc.h>
#define NULL 0
int main(){
struct node{
int data;
struct node *link;
};
struct node *p,*q;
p=(struct node *) malloc(sizeof (struct node));
q=(struct node *) malloc(sizeof (struct node));
p->data=30;
p->link=q;
q->data=40;
q->link=NULL;
printf("%d
",p->data);
p=p->link;
printf("%d
",p->data);
return 0;
}
What will be the output of the following program on GCC?
Practice Pointers –
What will be the output of the following program on GCC?
#include <stdio.h>
int main(){
float *jam(float *);
float p=23.5,*q;
//let the address of p=852.
q=&p;
printf("q before call=%u
",q);
q=jam(&p);
printf("q after call=%u
",q);
return 0;
}
float *jam(float *r){
r = r +1;
return (r);
}
What will be the output of the folllowing program on GCC compiler?<
Practice Pointers –
What will be the output of the folllowing program on GCC compiler?
#include <stdio.h>
int main(){
int a[] = {2,4,6,8,10};
int i;
for(i=0;i<=4;i++){
*(a+i)=a[i] + i[a];
printf("%d,",*(i+a));
}
return 0;
}