CODE JAM Round1
CODE JAM Round1
#include<stdio.h>
int main()
{
printf(5+"Good Morning\n");
return 0;
}
#include<stdio.h>
int main(int argc, char *argv[])
{
int i;
for(i=1; i<argc; i++)
printf("%c", argv[i][0]);
return 0;
}
Q.3 Give the output of the following code:
#include<stdio.h>
int main()
{
enum value{VAL1=0, VAL2, VAL3, VAL4, VAL5} var;
printf("%d\n", sizeof(var));
return 0;
}
#include<stdio.h>
const char *fun();
int main()
{
*fun() = 'A';
return 0;
}
const char *fun()
{
return "Hello";
}
Q.5 How many times the while loop will get excecuted if a
short int is 2 byte wide?
#include<stdio.h>
int main()
{
int j=1;
while(j <= 255)
{
printf("%c %d\n", j, j);
j++;
}
return 0;
}
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
Q.7 What will the output of the following code?
#include<stdio.h>
int main()
{
static int a[20];
int i = 0;
a[i] = i ;
printf("%d, %d, %d\n", a[0], a[1], i);
return 0;
}
#include<stdio.h>
int main()
{
printf("IndiaBIX");
main();
return 0;
}
Q.9 How will you free the memory allocated by the following
program?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main()
{
int **p, i, j;
p = (int **) malloc(MAXROW * sizeof(int*));
return 0;
}
void main(){
int a=2;
switch(a)
{
case4: printf("A");
break;
case3: printf("B");
case2: printf("C");
case1: printf("D");
break;
default: printf("E");
}
}
Q.11 What will be printed as the result of the operation
below?
main()
{
char s1[]="Cisco"
char s2[]= "systems";
printf("%s",s1);
}
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);
void main()
{
int a,b;
a=15; b=25;
a=a+b;
b=a-b;
a=a-b;
printf("%d%d",a,b);
}
Q.14 What will be the output when the following code is
executed?
main()
{
int i;
i = 10;
printf("%d\t",5,6);
printf("%d", i , i++);
}
void main(){
int a,b,c,d;
a=b=c=d=1;
a=++b>1 || ++c>1 && ++d>1;
printf("%d%d%d",a,b,c,d);
}
#include<stdio.h>
int main()
{
printf("India", "BIX\n");
return 0;
}
Q.17 Which of the following statements are correct in the
program given below?
#include<stdio.h>
int main()
{
float a=1.5, b=1.55;
if(a=b)
printf("a and b are equal\n");
else
printf("a and b are not equal\n");
return 0;
}
#include<stdio.h>
int main()
{
int x=55;
printf("%d, %d, %d\n", x<=55, x=40, x>=10);
return 0;
}
Q.19 How many times the program will print “GTU-
TECHFEST”?
#include<stdio.h>
int main()
{
printf("GTU-TECHFEST");
main();
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1,b=2,c;
clrscr();
c=a++ + b;
++b = +a;
printf("%d %d %d ",++a,b,c);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a= ?,b=?,c=?;
clrscr();
b=+b + ++a + --c - a++;
printf("%d %d %d ",++a-c,b+b,c- --a);
getch();
}
Q.23 From the above solve further.
#include<stdio.h>
#include<conio.h>
void main()
{
int a=?,b=?,c=-?,i;
clrscr();
for(i=c;i<b; ++i)
{
c++;
b--;
if(i==a)
break;
}
b<c?a=b:a=c;
printf("%d %d %d ",a,b,c);
getch();
}
Q.24 Point out the error in the program.
#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned char;
FILE *fp;
fp=fopen("trial", "r");
if(!fp)
{
printf("Unable to open file");
exit(1);
}
fclose(fp);
return 0;
}
#include<stdio.h>
int main()
{
char ch;
int i;
scanf("%c", &i);
scanf("%d", &ch);
printf("%c %d", ch, i);
return 0;
}
Q.26 What is the output of the following program?
#include<stdio.h>
/* Assume there is a file called 'file.c' in c:\tc directory. */
int main()
{
FILE *fp;
fp=fopen("c:\tc\file.c", "r");
if(!fp)
printf("Unable to open file.");
fclose(fp);
return 0;
}
#include<stdio.h>
int main()
{
unsigned char ch;
FILE *fp;
fp=fopen("trial", "r");
while((ch = getc(fp))!=EOF)
printf("%c", ch);
fclose(fp);
return 0;
}
Q.28 What will be the output of the program?
try
{
int x = 0;
int y = 5 / x;
}
catch (Exception e)
{
System.out.println("Exception");
}
catch (ArithmeticException ae)
{
System.out.println(" Arithmetic Exception");
}
System.out.println("finished");
Q.29 What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod()
{
throw new Error(); /* Line 22 */
}
}
Q.30 What will be the output of the program?
****************************************************