Login
Register
@
Dark Mode
Profile
Edit my Profile
Messages
My favorites
Register
Activity
Q&A
Questions
Unanswered
Tags
Subjects
Users
Ask
Previous Years
Blogs
New Blog
Exams
Dark Mode
made easy test series
ck
asked
in
Programming in C
Aug 24, 2018
edited
Aug 24, 2018
by
ck
508
views
0
votes
0
votes
what is the value of z?
#include <stdio.h>
int main() {
int a[]={3,5,6,4};
int z=0;
for (int y=0;y<(sizeof(a)/sizeof int);y++)
z=a[y]+value(a[y]);
}
int value(int *x)
{
static int count;
while(*x)
{
count=count+*x&1;
*x>>1 ;
}
}
ck
asked
in
Programming in C
Aug 24, 2018
edited
Aug 24, 2018
by
ck
by
ck
508
views
answer
comment
Follow
share this
share
4 Comments
Show 3 previous comments
by
MiNiPanda
commented
Aug 24, 2018
reply
Follow
share this
int value(int *x)
x is a pointer variable that can hold the address of an integer.
value(a[y]) means you are passing an integer value and not it's address. For the prog to run properly we should pass the address of a[y].
Also there is not return statement in the function but the return type is of int. I guess it should be return count .. :/
0
0
by
srestha
commented
Aug 24, 2018
reply
Follow
share this
though print statement not given
but function value() will count number of 1's in each element of the array
0
0
by
newdreamz a1-z0
commented
Sep 5, 2018
reply
Follow
share this
count=((count+(*x))&1)
is this is the right way to resolve the precedence? if not then which order should i follow.
0
0
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
0
votes
0
votes
Best answer
I think the answer is 11
as the count variables count the number of 1 in the binary representation of array elements.
sandygate
answered
Aug 24, 2018
selected
Sep 5, 2018
by
ck
by
sandygate
comment
Follow
share this
2 Comments
by
Rishav Kumar Singh
commented
Aug 25, 2018
reply
Follow
share this
If you are not confirm then post it as comment not as answer, please.
2
2
by
Abbas
commented
Sep 6, 2018
reply
Follow
share this
@sandygate: can you explain??
0
0
Please
log in
or
register
to add a comment.
← Previous
Next →
← Previous in category
Next in category →
Related questions
0
votes
0
votes
1
answer
1
Rohit Chakraborty
asked
in
Programming in C
Jan 11
117
views
Made easy Test series
Can you please explain the whole working of the code
Rohit Chakraborty
asked
in
Programming in C
Jan 11
by
Rohit Chakraborty
117
views
made-easy-test-series
programming
0
votes
0
votes
1
answer
2
tishhaagrawal
asked
in
Programming in C
Dec 16, 2023
304
views
Made Easy Test Series : Consider an open addressing hashing scheme with m slots and n keys. Assuming uniform hashing, the expected number of empty slots in the hash table for m=7 and n=3 is equal to ____________(Round off to two decimal places)
tishhaagrawal
asked
in
Programming in C
Dec 16, 2023
by
tishhaagrawal
304
views
hashing
uniform-hashing
data-structures
doubt
made-easy-test-series
0
votes
0
votes
1
answer
3
tishhaagrawal
asked
in
Programming in C
Nov 22, 2023
395
views
Made Easy test series. Doubt: My output for this question is => 1,2 and this isn't present in any of the options. Can someone please help me understand this, as per my logic, I am terminating the loop at i= 4 because of short circuit due to OR operation. Please let me know if this approach is correct or I am missing out on something.
tishhaagrawal
asked
in
Programming in C
Nov 22, 2023
by
tishhaagrawal
395
views
programming-in-c
gate-preparation
made-easy-test-series
test-series
0
votes
0
votes
1
answer
4
jugnu1337
asked
in
Programming in C
Oct 22, 2023
340
views
made easy test series
Suppose A is a 12 by 9 incidence matrix from a connected (but unknown) graph with 9 nodes and 12 edges. The diagonal entries of $A^{T}.A$ give the number of edges into each node. Then, what is the sum of those diagonal entries ________.
jugnu1337
asked
in
Programming in C
Oct 22, 2023
by
jugnu1337
340
views
graph-theory
Subscribe to GATE CSE 2024 Test Series
Subscribe to GO Classes for GATE CSE 2024
Quick search syntax
tags
tag:apple
author
user:martin
title
title:apple
content
content:apple
exclude
-tag:apple
force match
+apple
views
views:100
score
score:10
answers
answers:2
is accepted
isaccepted:true
is closed
isclosed:true
Recent Posts
Post GATE 2024 Guidance [Counseling tips and resources]
GATE CSE 2024 Result Responses
[Project Contest] Pytorch backend support for MLCommons Cpp Inference implementation
Participating in MLCommons Inference v4.0 submission (deadline is February 23 12pm IST)
IIITH PGEE 2024 Test Series by GO Classes
Subjects
All categories
General Aptitude
(3.5k)
Engineering Mathematics
(10.4k)
Digital Logic
(3.6k)
Programming and DS
(6.2k)
Programming
(4.1k)
Programming in C
(4.1k)
Programming in Python
(5)
DS
(2.0k)
Algorithms
(4.8k)
Theory of Computation
(6.9k)
Compiler Design
(2.5k)
Operating System
(5.2k)
Databases
(4.8k)
CO and Architecture
(4.0k)
Computer Networks
(4.9k)
Artificial Intelligence
(79)
Machine Learning
(48)
Data Mining and Warehousing
(25)
Non GATE
(1.4k)
Others
(2.7k)
Admissions
(684)
Exam Queries
(1.6k)
Tier 1 Placement Questions
(17)
Job Queries
(80)
Projects
(11)
Unknown Category
(870)
64.3k
questions
77.9k
answers
244k
comments
80.0k
users
Recent Blog Comments
category ?
Hi @Arjun sir, I have obtained a score of 591 in ...
download here
Can you please tell about IIT-H mtech CSE self...
Please add your admission queries here:...
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy