GATE CSE · 2020 · CS
Question 48: Programming and Data Structures
Give it a try, then reveal the answer to check your work.
Question 48
CSNAT2 marksNeeds review
Consider the following C functions.
int tob(int b, int* arr) {
int i;
for(i=0; b>0; i++) {
if(b%2) arr[i]=1;
else arr[i]=0;
b = b/2;
}
return(i);
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b,arr);
for(i=0; i<len; i++) {
if(arr[i]==1)
tot = tot * ex;
ex = ex * ex;
}
return(tot);
}
The value returned by pp(3,4) is ______.
Log in to check the answer
You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answerEXPLORE & PRACTISE
Paper and topic context
See where this question comes from and choose what to practise next.
2020CS
GATE CSE 2020 · Paper 1
Computer Science and Information Technology · Original paper archive
- Section
- Computer Science and Information Technology
- Question type
- Numerical answer (NAT)
- Marks
- 2 marks
Practise related topics
Explore more previous year questions using this question’s imported topic tags.
computer science
GATE CSE previous year questions
information technology
GATE CSE previous year questions
computing
GATE CSE previous year questions
programming data structures
GATE CSE previous year questions
Programming and Data Structures
GATE CSE previous year questions
Comments
Ask a question, share your approach, or help someone understand.
Log in to view the discussion
You’re not logged in. Log in or create an account to see discussions and add comments.