Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

TRY IT YOURSELF : C: 1) How many times would "Hello World" get printed? #include<stdio.

h> int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("Hello World"); } return 0; 2) How many times the while loop will get executed if a long int is 2 byte wide? #include<stdio.h> int main() { long j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } 4) Write a C program to print Campus Force training without using even a single semicolon in the program. 5) Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

6) There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

JAVA: 1. Why do all the below statements result in -1? System.out.println(-1>>72); System.out.println(-1>>0); And System.out.println(-1>>-1);

2. What will this code print and why? public class Test{ public static void main(String str[]){ System.out.println(011); }} 3. What are the number systems that Java supports? Why should we have so many number systems?

4. Write a code that gets 8 yes or no answers from the user and verify if they are correct. Use one byte variable to store answer and one byte to store user answer. (Hint: since byte has 8 bits, 1 can be used to indicate yes and 0 can be used to indicate no).

DID YOU KNOW?


1) Odontophobia is the fear of teeth

2) The word Karaoke originally means "empty orchestra" .It is derived from the Japanese words Kara- empty and oke- "orchestra," shortened form of okesutora 3) Months that begin on a Sunday will always have a "Friday the 13th." 4) There are twice as many kangaroos in Australia as there are people. The kangaroo population is estimated at about 40 million 5) Wrigleys gum was the first product to have a bar code 6) Earth is the only planet not named after a god 7) Google is a version of the word Googol, which is the number 1 followed by 100 zeroes, representing the large number of web pages Google searches. 8) Wikipedia is formed from the Hawaiian word, wiki (meaning quick) and the word encyclopedia(meaning complete knowledge)

You might also like