Where is the error in the following code?
public class HelloWorld
{
public static void main(String[] args) {
System.out.println("Hello World!"):
}
}
What is a semicolon?
What language is the following code?
a = 2
b = 4
maximum = max(a, b)
print(maximum)
What is python?
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter a positive integer: ";
cin >> n;
for (int i = 1; i <= 10; ++i) {
cout << n << " * " << i << " = " << n * i << endl;
}
return 0;
}
What is a for loop?
What type of banching is used below?
int x = 20;
int y = 18;
if (x > y) {
cout << "x is greater than y";
}
What is an if?
This person coined the term "bug" in relation to computers.
Who is Grace Hopper?
What is the error in the following code?
What is ?
What language is the following code?
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float a, b, c, x1, x2, discriminant, realPart, imaginaryPart;
cout << "Enter coefficients a, b and c: ";
cin >> a >> b >> c;
discriminant = b*b - 4*a*c;
if (discriminant > 0) {
x1 = (-b + sqrt(discriminant)) / (2*a);
x2 = (-b - sqrt(discriminant)) / (2*a);
cout << "Roots are real and different." << endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
else if (discriminant == 0) {
cout << "Roots are real and same." << endl;
x1 = -b/(2*a);
cout << "x1 = x2 =" << x1 << endl;
}
else {
realPart = -b/(2*a);
imaginaryPart =sqrt(-discriminant)/(2*a);
cout << "Roots are complex and different." << endl;
cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;
}
return 0;
}
What is C++?
#include <iostream>
using namespace std;
int main() {
int n, reversedNumber = 0, remainder;
cout << "Enter an integer: ";
cin >> n;
while(n != 0) {
remainder = n%10;
reversedNumber = reversedNumber*10 + remainder;
n /= 10;
}
cout << "Reversed Number = " << reversedNumber;
return 0;
}
What is a while loop?
What type of banching is used below?
int time = 22;
if (time < 10) {
cout << "Good morning.";
} else {
cout << "Good evening.";
}
What is an if else?
The computing language of FORTRAN, still in use today, was first created in which year.
What is 1957?
What is the error in the following code?
n=11
for i in range (n, 0, -1):
print((n-i) * ' ' + i ** '*')
What is *?
What language is the following code?
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);
// %d displays the integer value of a character
// %c displays the actual character
printf("ASCII value of %c = %d", c, c);
return 0;
}
What is C?
#include <iostream>
using namespace std;
int main() {
int n1, n2, hcf;
cout << "Enter two numbers: ";
cin >> n1 >> n2;
// swapping variables n1 and n2 if n2 is greater than n1.
if ( n2 > n1) {
int temp = n2;
n2 = n1;
n1 = temp;
}
for (int i = 1; i <= n2; ++i) {
if (n1 % i == 0 && n2 % i ==0) {
hcf = i;
}
}
cout << "HCF = " << hcf;
return 0;
}
What is a for loop?
If there are two conditions that need to be explicitly stated, what is the name of the second condition?
What is an else if?
The C Programming Language was released in which year?
What is 1972?
What is the error in the following code?
public class CallingMethodsInSameClass
{
public static void main(String[] args) {
printOne;
printOne;
printTwo;
}
public static void printOne() {
System.out.println("Hello World");
}
public static void printTwo() {
printOne;
printOne;
}
}
What is ()?
What language is the following code?
public class Main {
public static void main(String[] args) {
// year to be checked
int year = 1996;
boolean leap = false;
// if the year is divided by 4
if (year % 4 == 0) {
// if the year is century
if (year % 100 == 0) {
// if year is divided by 400
// then it is a leap year
if (year % 400 == 0)
leap = true;
else
leap = false;
}
// if the year is not century
else
leap = true;
}
else
leap = false;
if (leap)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
}
What is Java?
#include <iostream>
using namespace std;
int main()
{
int n1, n2, max;
cout << "Enter two numbers: ";
cin >> n1 >> n2;
// maximum value between n1 and n2 is stored in max
max = (n1 > n2) ? n1 : n2;
do
{
if (max % n1 == 0 && max % n2 == 0)
{
cout << "LCM = " << max;
break;
}
else
++max;
} while (true);
return 0;
}
What is a do-while?
If there are no other specific options for a switch statement what is the last statement named?
What is default?
This person published in On Computable Numbers, in 1936 in which he theorized about the nature of human and machine intelligence.
Who is Alan Turing?
What is the error in the following code?
#include <stdio.h>
#define LAST 10
int main()
{
int i;
int sum = 0;
for ( i = 1; i <= LAST; i++ ) {
sum += i;
}
printf("sum = /d\n", sum);
return 0;
}
What is /?
What language is the following code?
namespace HelloWorld
{
class Hello {
static void Main(string[] args)
{
System.Console.WriteLine("Hello World!");
}
}
}
What is C#?
#include <iostream>
using namespace std;
int main() {
int i = 1;
// do...while loop from 1 to 5
do {
cout << i << " ";
++i;
}
while (i <= 5);
return 0;
}
What is a do while?
int day = 4;
switch (day) {
case 1:
cout << "Monday";
break;
case 2:
cout << "Tuesday";
break;
case 3:
cout << "Wednesday";
break;
case 4:
cout << "Thursday";
break;
case 5:
cout << "Friday";
break;
case 6:
cout << "Saturday";
break;
case 7:
cout << "Sunday";
break;
}
What is a switch statement?
In which year was the MIT Media Lab founded?
What is 1985?