Arithmetic Operation


Question 1
What is printed by the following ANSI C program?
#include < stdio.h >
int main(int argc, char *argv[]){ 
 char a = 'P';
 char b = 'x';
 char c = (a  &  b) + '*';
 char d = (a | b) - '-';
 char e = (a ^ b) + '+'; 
 printf("%c %c %c \n", c, d, e); 
 return 0;
}

ASCII encoding for relevant characters is given below

A
z K S
B
122 75 83
C
* - +
D
P x +
GATE CSE 2022   C Programming
Question 2
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 3
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 4
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 5
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


There are 5 questions to complete.

4 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