Vous êtes sur la page 1sur 2

DEPARTMENT OF CIVIL ENGINEERING

CPC - DIAGNOSTIC SOFTWARE TEST



Max Marks: 50 By- Bipul
Total Time: 45 Minutes

Guidelines :
3 years of studying Civil doesnt guarantee you a job but basic programming knowledge
most definitely will. Take this paper seriously!
We know you havent been taught programming (1
st
semester was a joke) at all. Well, life
is unfair!
Most of you will only laugh and look at each other once you get this paper. You can do
that even after these torturous 45 minutes. Concentrate!
Do attempt all the questions and please avoid writing crap. We know you think final years
are jobless but believe me; we still have a lot of sitcoms to watch!
All the best and go for it. It cant get easier than this.

Questions 1-6 carry 2 marks each. Find errors if any, else give only output for the code or code
segment. Assume all necessary header files are included in the program.

1. main()
{ int a=10;
void f();
a=f();
pritf(\n%d,a);
}
void f()
{ printf(\nHi);
}

2. #define AREA(x) (3.14*x*x)
void main()
{ float r=3,a;
a=AREA(r);
printf("%f ",a);
a=AREA(r+2);
printf("%f",a);
}

3. void main()
{ char arr[] = CEA;
char *ptr = Moments11;
arr = Civil Engineering Associaation;
ptr = Moments12;
printf(%s presents %s,arr,ptr);
}

4. main()
{ int i=-3, j=2, k=0,m;
m=++j && ++i II ++k;
printf(\n %d %d%d%d,i,j,k,m);
}
5. void main()
{ int i;
for(i=0;i<3;i++)
{int i=100;
i--;
printf ("%d.. ",i);
}

6. void main()
{
int i = 0;
for(int i = 0 ;i < 26 ; i += 2)
printf("%c",i["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]);
}

7. What is typecasting? (2)

8. Name the different types of sorting algorithms? (any 6) (3)

9. List all the data types in C in the increasing order of sizes. (2)

10. Differentiate briefly the following with illustrative code segments. (14)
A. Local and global variables
B. Call by reference and Call by value
C. Runtime error and Syntax error
D. Structure and array
E. For loop and do while loop
F. Break and continue
G. Logical operator and Arithmetic operator

11. Write a code segment to Swap two values a = 10 and b = 30 without using a third variable. (2)

12. Write a program to calculate factorial of a number with and without recursion (3+3)

13. Write a program to find if the given number is palindrome or not. For example, the number
4321234 is a palindrome as it reads the same from left to right and from right to left. (5)
(Do not use an integer array)

14. Write a program to find LCM of two numbers. (4)

Vous aimerez peut-être aussi