[go: up one dir, main page]

0% found this document useful (0 votes)
55 views6 pages

Quiz About C Advanced Pointer

The document contains a series of programming questions related to C language, focusing on pointers, memory allocation, and output predictions. Each question presents a code snippet and multiple-choice answers for users to select the correct output. The document is structured for practice and discussion, aimed at enhancing understanding of advanced C programming concepts.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views6 pages

Quiz About C Advanced Pointer

The document contains a series of programming questions related to C language, focusing on pointers, memory allocation, and output predictions. Each question presents a code snippet and multiple-choice answers for users to select the correct output. The document is structured for practice and discussion, aimed at enhancing understanding of advanced C programming concepts.

Uploaded by

chandra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Tutorials

Search... Sign In
Practice
Jobs
DSA Practice Problems C C++ Java Python JavaScript Data Science Machine Learning Courses Linux DevOps SQL Web Develop

C Advanced Pointer
Last Updated : Mar 22, 2024 Discuss

Question 1

void fun(int *p)


{
int q = 10;
p = &q;
}

int main()
{
int r = 20;
int *p = &r;
fun(p);
printf("%d", *p);
return 0;
}

A 10

B 20

C Compiler error

D Runtime Error

Discuss it

Question 2

Assume sizeof an integer and a pointer is 4 byte. Output?

#include <stdio.h>

#define R 10
#define C 20

int main()
{
int (*p)[R][C];
printf("%d", sizeof(*p));
getchar();
return 0;
}

A 200

B 4

C 800

D 80
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
Got It !
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Discuss it
Question 3

#include <stdio.h>
int main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d", *(a+1), *(ptr-1));
return 0;
}

A 25

B Garbage Value

C Compiler Error

D Segmentation Fault

Discuss it

Question 4

#include <stdio.h>

char *c[] = {"GeksQuiz", "MCQ", "TEST", "QUIZ"};


char **cp[] = {c+3, c+2, c+1, c};
char ***cpp = cp;

int main()
{
printf("%s ", **++cpp);
printf("%s ", *--*++cpp+3);
printf("%s ", *cpp[-2]+3);
printf("%s ", cpp[-1][-1]+1);
return 0;
}

A TEST sQuiz Z CQ

B MCQ Quiz Z CQ

C TEST Quiz Z CQ

D GarbageValue sQuiz Z CQ

Discuss it

Question 5

Predict the output

We use cookies
#include to ensure you have the best browsing experience on our website. By using our site, you
<string.h>
#include acknowledge
<stdio.h> that you have read and understood our Cookie Policy & Privacy Policy
#include <stdlib.h>

void fun(char** str_ref)


{
str_ref++;
}

int main()
{
char *str = (void *)malloc(100*sizeof(char));
strcpy(str, "GeeksQuiz");
fun(&str);
puts(str);
free(str);
return 0;
}

A GeeksQuiz

B eeksQuiz

C Garbage Value

D Compiler Error

Discuss it

Question 6

Assume that the size of int is 4.

#include <stdio.h>
void f(char**);
int main()
{
char *argv[] = { "ab", "cd", "ef", "gh", "ij", "kl" };
f(argv);
return 0;
}
void f(char **p)
{
char *t;
t = (p += sizeof(int))[-1];
printf("%s\\n", t);
}

A ab

B cd

C ef

D gh

Discuss it

Question 7

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
A 2356

B 2345

C 4500

D none of the above

Discuss it

Question 8

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int i;
int *ptr = (int *) malloc(5 * sizeof(int));

for (i=0; i<5; i++)


*(ptr + i) = i;

printf("%d ", *ptr++);


printf("%d ", (*ptr)++);
printf("%d ", *ptr);
printf("%d ", *++ptr);
printf("%d ", ++*ptr);
}

A Compiler Error

B 01223

C 01234

D 12345

Discuss it

Question 9

Output of following program

#include <stdio.h>
int fun(int arr[]) {
arr = arr+1;
printf("%d ", arr[0]);
}
int main(void) {
int arr[2] = {10, 20};
fun(arr);
printf("%d", arr[0]);
return 0;
}

A Compiler Error

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
B 20 10
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
C 20 20

D 10 10

Discuss it

Question 10

What is printed by the following C program?

$include <stdio.h>
int f(int x, int *py, int **ppz)
{
int y, z;
**ppz += 1;
z = **ppz;
*py += 2;
y = *py;
x += 3;
return x + y + z;
}

void main()
{
int c, *b, **a;
c = 4;
b = &c;
a = &b;
printf( "%d", f(c,b,a));
getchar();
}

A 18

B 19

C 21

D 22

Discuss it

Tags: C Quiz

There are 19 questions to complete.

Take a part in the ongoing discussion View All Discussion

Company Explore Tutorials DSA Data Science & Web


About Us Job-A-Thon Python Data Structures
We use cookies to ensure you have the best browsing experience on our website. By using our site, you ML Technologies
Legal Java Algorithms
acknowledge that you have read and understood our Cookie Policy & Privacy Policy HTML
Privacy Policy C++
Corporate & Communications Careers Offline PHP DSA for Data Science With CSS
Address: In Media Classroom GoLang Beginners Python JavaScript

A-143, 7th Floor, Contact Us Program SQL Basic DSA Machine Learning TypeScript
Sovereign Corporate Corporate DSA in R Language Problems ML Maths ReactJS
Tower, Sector- 136, Noida, Solution JAVA/C++ Android DSA Roadmap Data Visualisation NextJS
Uttar Pradesh (201305) Campus Master DSA Interview Pandas NodeJs

Registered Address: Training System Questions NumPy Bootstrap


Program Design Competitive NLP Tailwind CSS
K 061, Tower K, Gulshan
Vivante Apartment, Sector Master CP Programming Deep Learning
137, Noida, Gautam Buddh Python Computer
Videos DevOps System School Databases
Nagar, Uttar Pradesh, Tutorial Science Git Design Subjects SQL
201305 GATE CS AWS Mathematics MYSQL
Python High Level
Examples Notes Docker Design Physics PostgreSQL

Django Operating Kubernetes Low Level Chemistry PL/SQL


Tutorial Systems Azure Design Biology MongoDB

Python Computer GCP UML Diagrams Social Science

Projects Network DevOps Interview Guide English Grammar

Python Database Roadmap Design Patterns


Tkinter Management OOAD
Advertise with us System
Web Scraping System Design
OpenCV Software Bootcamp
Tutorial Engineering Interview
Python Digital Logic Questions
Interview Design

Question Engineering
Maths

Preparation More Courses Programming Clouds/Devops GATE 2026


IBM Languages DevOps GATE CS Rank
Corner Tutorials
Certification C Programming Engineering Booster
Company- Software
Courses with Data AWS Solutions GATE DA Rank
Wise Development
DSA and Structures Architect Booster
Recruitment Software
Placements C++ Certification GATE CS & IT
Process Testing
Web Programming Salesforce Course - 2026
Aptitude Product
Development Course Certified GATE DA
Preparation Management
Data Science Java Administrator Course 2026
Puzzles Project
Programming Programming Course GATE Rank
Company- Management
Languages Course Predictor
Wise Linux
DevOps & Python Full
Preparation Excel
Cloud Course
All Cheat
Sheets

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy

You might also like