Arithmetic Operation

Question 1
Consider the following C program:

#include < stdio.h >
int main() {
 float sum = 0.0, j = 1.0, i = 2.0;
 while (i / j > 0.0625) {
    j = j + j; 
    sum = sum + i/j;
    printf("%f \n", sum);
 }
 return 0;
}
The number of times variable sum will be printed When the above program is executed is _________ .
A
0
B
3
C
6
D
5
GATE CSE 2019   C programming
Question 2
Consider the following C program:
 main()
{
float sum= 0.0, j=1.0,i=2.0;
while(i/j>0.001){
    j=j+1;
    sum=sum+i/j;
    printf("%f/n", sum);
  }
}
A
0 - 9 lines of output
B
10 - 19 lines out output
C
20 - 29 lines of output
D
More than 29 lines of output
ISRO CSE 2018   C Programming
Question 3
Consider the following C code segment:
 #include < stdio.h >
main()
{
    int i, j, x;
    scanf("%d", &x);
    i=1; j=1;
    while (i<10) {
            j =j*i;
            i= i+1;
            if(i==x) break;
        }
}
For the program fragment above, which of the following statements about the variables i and j must be true after execution of this program? [ !(exclamation) sign denotes factorial in the answer]
A
(j=(x-1) !) \wedge(i \geq x)
B
(j=9 !) \wedge(j=10)
C
((j=10 !) \wedge(i=10)) \vee((j=(x-1) !) \wedge(i=x))
D
(j=9 !) \wedge(i \geqslant 10)) \vee((j=(x-1) !) \wedge(i=x))
ISRO CSE 2018   C Programming
Question 4
What does the following program do when the input is unsigned 16 bit integer?
 #include < stdio.h >
main(){
  unsigned int num;
  int i;
  scanf("%u", &num);
  for(i=0;i<16;i++){
    printf("%d", (num < < i&1 < < 15)?1:0);
  }
}
A
It prints all even bits from num
B
It prints all odd bits from num
C
It prints binary equivalent of num
D
None of above
ISRO CSE 2017   C Programming
Question 5
Consider the following C program.
 #include < stdio.h >
int main ( ) {
    int m = 10;
    int n, n1;
    n = ++m;
    n1 = m++;
    n--;
    --n1;
    n-=n1;
printf ("%d", n) ;
return 0;
}
The output of the program is ______________.
A
10
B
11
C
1
D
0
GATE CSE 2017 SET-2   C Programming
Question 6
The attributes of three arithmetic operators in some programming language are given below.

The value of the expression 2-5+1-7*3 in this language is_______ .
A
-23
B
9
C
-27
D
23
GATE CSE 2016 SET-1   C Programming
Question 7
Consider the following statements
 #define hypotenuse (a, b) sqrt (a*a+b*b);
The macro call hypotenuse(a+2,b+3);
A
Finds the hypotenuse of a triangle with sides a+2 and b+3
B
Finds the square root of (a+2)^{2} and (b+3)^{2}
C
Is invalid
D
Find the square root of 3*a+4*b+5
ISRO CSE 2015   C Programming
Question 8
The for loop
 for (i=0; i<10; ++i)
printf("%d", i&1);
prints
A
0101010101
B
0111111111
C
0000000000
D
1111111111
ISRO CSE 2015   C Programming
Question 9
Consider the following program fragment
 i=6720; j=4;
while (i%j)==0
{
    i=i/j;
    j=j+1;
}
On termination j will have the value
A
4
B
8
C
9
D
6720
ISRO CSE 2015   C Programming
Question 10
If n has 3, then the statement a[++n]=n++;
A
assigns 3 to a[5]
B
assigns 4 to a[5]
C
assigns 4 to a[4]
D
what is assigned is compiler dependent
ISRO CSE 2015   C Programming
There are 10 questions to complete.

2 thoughts on “Arithmetic Operation”

  1. Dear Practise paper Team,

    This website is extremely useful to solve PYQs.
    But only if it had an option of bookmarking the question, We could completely depend on this website for PYQs.

    As you know, How important it is to mark the important questions. so that we can solve it again later.
    I humbly request the team to add this feature by making user accounts.

    Thanks & Warm Regards

    Reply

Leave a Comment

Like this FREE website? Please share it among all your friends and join the campaign of FREE Education to ALL.