Anda di halaman 1dari 2

DEPARTMENT OF CIVIL ENGINEERING

CPC - DIAGNOSTIC SOFTWARE TEST



Max Marks: 50 Total Time: 45 Minutes

Questions 1-7 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. void main()
{
int array[]={2,3,4,5};
int *arptr=array;
int value=*arptr; cout<<value<<"\t";
value=*arptr++; cout<<value<<"\t";
value=*arptr; cout<<value<<"\t";
value=*++arptr; cout<<value<<"\t";
}

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. int a=2,b=5;
if(a>b) cout<<(a|b);
else cout<<(a&b);



5. static int z = 2 || 1 / 0;
int main()
{
printf("z = %d\n",z);
return 0;
}

6. void main()
{
printf("%d %d %d %d\n",sizeof(void *),sizeof(char *),sizeof(int *),sizeof(double *));
}

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

8. Name the header files for the following: (2)
A. random B. setw C. isalpha D. gets

9. What are access specifiers? Explain with examples. (3)

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

11. 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

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

13. Write a function in C/C++ to print the Pascals triangle. If input is 4, then the output will be
1
1 2 1 (4)
1 2 3 2 1
1 2 3 4 3 2 1

14. 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)

15. Write a program to find GCD of two numbers. (4)

Anda mungkin juga menyukai