Vous êtes sur la page 1sur 5

Sreenivasa Institute of Technology and Management Studies (Autonomous)::Chittoor

Placement Training Programme-(2017-2018)


C Programming
WEEK -1b [VARIABLES, DATATYPES, EXPRESSIONS AND OPERATORS]
Part -A

1. Which of the following operator takes only integer operands?


(A) + (B)* (C)/ (D)% (E)None of these

2.
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
What is the output of the above program?
(A) 3 (B) 4 (C) 5 (D) Compile-time

3.
#include <stdio.h>
int main()
{
int i = 5, j = 10, k = 15;
printf("%d\t" , sizeof(k/= i + j));
printf("%d", k);
return 0;
}
Assume size of an integer as 4 bytes. What is the output of above program?
(A) 4 1 (B) 4 15 (C) 2 1 (D) Compile-time error

4. Predict the output for the program given below.


#include <stdio.h>
int main()
{
//Assume sizeof character is 1 byte and sizeof integer is 4 bytes
printf("%d", sizeof(printf("GeeksQuiz")));
return 0;
}
(A) GeeksQuiz4 (B) 4GeeksQuiz (C) GeeksQuiz9 (D) 4
(E) Compile-time error
5. Determine the output for the program given below.
#include <stdio.h>
void main()
{
int c = - -2;
printf("c=%d", c);
}
(A) 1 (B) -2 (C) 2 (D) Compile-time error

6. What will be output of the following program?

#include<stdio.h>
int main(){
int i=1;
i=2+2*i++;
printf("%d",i);
return 0;
}

7. What will be output of the following program?


#include<stdio.h>
int main(){
int x;
x=10,20,30;
printf("%d",x);
return 0;
}

8. What will be output of the following program?

#include<stdio.h>
int main(){
printf("%d %d %d",sizeof(3.14),sizeof(3.14f),sizeof(3.14L));
return 0;
}

9. What will be output of the following program?


#include<stdio.h>
int main(){
float a;
(int)a= 45;
printf("%d,a);
return 0;
}
10. Determine the output for the program given below.
main()
{
int a,b;
a=-3 - -3;
b=-3 - -(-3);
printf("a=%d \n b=%d",a,b);
}

11. By default a real number is treated as a


a) float b) double c) long double d) far double

Find the bug/s in the following programs (12 to 15):


12.
void main()
{
unsigned int d=65535;
unsigned char p=65;
printf("d=%c \n p=%c",d,p);
}

13.
void main()
{
int d=35;
const p=25;
printf("d=%d \ p=%d" d,p);
}

14.
#define
#define N=10
void main()
{
int x=10,p;
p=x*N;
printf("\n p=%d",p);
}
15
void main()
{
float d=123456.743 ;
double p 987654321.1234567;
printf("\n%f %lf",d,p);
printf( \n%d %d", sizeof(d), size of(p));
}

Part -B

1. Write a program to shift input data by two bits to the left.

2. Write a C code for each of the following formulas. Assume that all variables are defined as double.

𝑚𝑣 2
a) kinetic_energy = 2

𝑏+𝑐
b) re = 2𝑏𝑐

3. Write the C code to calculate and print the next two numbers in each of the following series. You
should use only variable in each problem.

a) 0,5,10,15,20,25,?,?

b) 0,2,4,6,8,10,?,?

c) 1,2,4,8,16,32,?,?

4. Write a program to round off an integer i to the next largest multiple of another integer j. For
example, 256 days when rounded off to the next largest multiple divisible by a week results in 259.

5. Write a program to find out how many days and how many weeks have passed between the dates
01/06/2017 to 31/12/2017. Also find out how many days, weeks and days leftover.

6. Consider the Data Types and Variable Declarations in example given below develop a program display
the output using appropriate format string.
int a = 4000; // positive integer data type
float b = 5.2324; // float data type
char c = 'Z'; // char data type
long d = 41657; // long positive integer data type
long e = -21556; // long -ve integer data type
int f = -185; // -ve integer data type
short g = 130; // short +ve integer data type
short h = -130; // short -ve integer data type
double i = 4.1234567890; // double float data type
float j = -3.55; // float data type

7. Write a program to display ASCII value for the following: numbers from 0 to 9, A to Z and a to z.

8. Write a program to enter a number that should be less that 100 and greater than 10. Display the
number in reverse order.
9. Write a program to print whether the number entered is even or odd. Use only conditional operator.

10. By considering the operator precedence, convert the following equation to C program.