Professional Documents
Culture Documents
• C++ Program :
#include <iostream><br>
int main()
{
cout << "Hello World" << endl;
return 0;
}
C Program
#include <stdio.h>
int main(int argc, char ** argv)
{
printf(“Hello, World!\n”);
}
Java Program :
public class Hello
{
public static void main(String argv[])
{
System.out.println(“Hello, World!”);
}
}
Python Program :
• print ( "Hello World")
COMPARISON WITH JAVA
• Python programs are typically 3-5 times shorter than equivalent Java
programs.
• Python code is often 5-10 times shorter than equivalent C++ code.
• ACM – ICPC
• Google Code Jam
• Topcoder Open
• Google foo bar challenge
• Facebook Hacker cup
QUIZ
1. Which of the following is not a storage class specifier in C?
(A) auto
(B) register
(C) static
(D) extern
(E) volatile
2. Assume that size of an integer is 32 bit. What is the output of following program?
#include<stdio.h>
struct st
{
int x;
static int y;
};
int main()
{
printf("%d", sizeof(struct st));
return 0;
}
(A) 4
(B) 8
(C) Compiler Error
(D) Runtime Error
3. How many times will PythonProgramming be printed in the given program?
#include <stdio.h>
int main()
{
int i = 1024;
for (; i; i >>= 1)
printf(“PythonProgramming");
return 0;
}
(A) 10
(B) 11
(C) Infinite
(D) The program will show compile-time error
4. Which of the following is true?
(A) All objects of a class share all data members of class
(B) Objects of a class do not share non-static members. Every object has
its own copy.
(C) Objects of a class do not share codes of non-static methods, they
have their own copy
(D) None of the above
5. What should be put in a try block?
1. Statements that might cause exceptions
2. Statements that should be skipped in case of an exception
(A) Only 1
(B) Only 2
(C) Both 1 and 2
(D) None of the above