Você está na página 1de 10

Assignment 3 Functions and Strings [Q001]. The following code is not well-written. What does the program do ?

void main() { int a=1,b=2; printf("%d",add(a,b)); } int add(int a,int b) { return (a+b); } (a)Run-Time Error (b)Compile-Time Error (c)3 (d)None of these [Q002]. What will be the output of the following program : int add(int a,int b) { int c=a+b; } void main() { int a=10,b=20; printf("%d %d %d",a,b,add(a,b)); } (a)10 20 0 (b)Compile-Time Error (c)10 20 30 [Q003]. What will be the output of the following program : int add(int a,int b) { int c=a+b; return; } void main() { int a=10,b=20; printf("%d %d %d",a,b,add(a,b)); } (a)10 20 0 (b)Compile-Time Error (c)10 20 30 (d)None of these

(d)None of these

[Q004]. What will be the output of the following program : void main() { int add(int,int); int a=7,b=13; printf("%d",add(add(a,b),add(a,b))); } int add(a,b) int a,b; { return (a+b); } (a)Compile-Time error (b)20 (c)40 [Q005]. What will be the output of the following program : int add(a,b) { int c=a+b; return c; } void main() { int a=10,b=20; printf("%d",add(a,b)); } (a)30 (b)Compile-Time Error (c)0

(d)None of these

(d)None of these

[Q006]. What will be the output of th`e following program : int funct2(int b) { if (b == 0) return b; else funct1(b--); } int funct1(int a) { if (a == 0) return a; else funct2(a--); } void main() { int a=7; printf("%d",funct1(a)); } (a)0 (b)Compile-Time Error (c)Infinite Loop

(d)7

[Q007]. What will be the output of the following program : int funct2(int b) { if (b == 0) return b; else funct1(--b); } int funct1(int a) { if (a == 0) return a; else funct2(--a); } void main() { printf("%d",funct1(a)); } (a)0 (b)Compile-Time Error (c)Infinite Loop [Q008]. What will be the output of the following program : int funct1(int a) {{;}{{;}return a;}} void main() { int a=17; printf("%d",funct1(a)); } (a)0 (b)Compile-Time Error (c)17 [Q009]. What will be the output of the following program : int funct1(int a) { if (a) return funct1(--a)+a; else return 0; } void main() { int a=7; printf("%d",funct1(a)); } (a)7 (b)21 (c)28 [Q010]. What will be the output of the following program :

(d)7

(d)None of these

(d)None of these

int compute(int a,int b) int c; { c=a+b; return c; } void main() { int a=7,b=9; printf("%d",compute(a,b)); } (a)Compile-Time Error (b)16 (c)None of these

[Q011]. What will be the output of the following program :

int a=10; void compute(int a) { a=a; } void main() { int a=100; printf("%d ",a); compute(a); printf("%d",a); }
(a)10 10 (b)Compile-Time Error (c)100 100 (d)100 10 [Q012]. What will be the output of the following program :

int funct(char ch) { ch=ch+1; return ch; } void main() { int a=127;

printf("%d %d",a,funct(a)); }
(a)Compile-Time Error (b)127 128 (c)127 -128 (d)None of these

[Q013]. What will be the output of the following program : char funct(int val) { char ch=val; return ch; } void main() { float a=256.25; printf("%d",funct(a)); } (a)0 (b)256.25 (c)256 (d)None of these [Q014]. What will be the output of the following program : auto int a; void changeval(int x) { a=x; } void main() { a=15; printf("%d",a); changeval(75); printf("%d",a); } (a)Compile-Time Error (b)15 75 (c)15 15 [Q015]. What will be the output of the following program : int val; static int funct() { return val*val; } void main() { val=5; funct(); val++; printf("%d",funct()); } (a)Compile-Time Error (b)25 (c)36

(d)None of these

(d)None of these

[Q016]. What will be the output of the following program : static int funct(int val) { static int sum; sum+=val; return sum; } void main() { int i,n=9; for (i=1; i<n--; i++) funct(i*2); printf("%d",funct(0)); } (a)20 (b)0 (c)30 [Q017]. What will be the output of the following program : void print(int a[],...) { while (*a != -1) printf("%d",*a++); } void main() { int a[]={1,2,3,4,5,-1}; print(a,5,6,7,8,9,-1); } (a)Compile-Time Error (b)Run-Time Error (c)12345 [Q018]. What will be the output of the following program : *); void print(int void print(int *); void main() { int x=100; print(&x); } void print(int *a) { printf("%d",*a); } (a)Compile-Time Error (b)Run-Time Error (c)100

(d)None of these

(d)56789

(d)None of these

[Q019]. What will be the output of the following program : void main() { void funct1(void); void funct2(void); clrscr(); funct1(); } void funct1(void) { printf("Ocean of "); funct2(); } void funct2(void) { printf("Knowledge"); } (a)Compile-Time Error (b)Run-Time Error (c)Ocean of Knowledge (d)None of these [Q020]. What will be the output of the following program : static int count=1; void funct3(void) { printf("%d",++count); } void funct2(void) { printf("%d",count); funct3(); } void funct1(void) { printf("Counting...%d",count++); funct2(); } void Main() { funct1(); } (a)Compile-Time Error (b)Counting...123 (c)Counting...111

(d)Counting...112

[Q021] What will be the output of the following program : int main() { char str[]="Welcome to ACCEL "; printf("%d",sizeof str); return(0); } [Q022] What will be the output of the following program : int main() { char str[]="Welcome to Accel"; printf("%d",++(sizeof(str))); return(0); } [Q023] What will be the output of the following program : int main() { char str[]="Welcome to ACCEL"; printf("%d",-sizeof(str)); return(0); }
[Q024] What will be the output of the following program :

int main() { char str[]="Welcome to ACCEL"; printf("%s",str); printf("\n%.5s",str); printf("\n%8.*s",5,str); printf("\n%-10s %.1s",str+6,str); return(0); } }

[Q025] What will be the output of the following program [NOTE : THE USER INPUT IS :A B C] : int main() { char a,b,c; scanf("%c%c%c",&a,&b,&c); printf("a=%c b=%c c=%c",a,b,c); return(0); } (a)a=A b=B c=C (b)a=A b= c=B (c)a=A b= c=C (d)None of these 1.Write a Program to find the LCM and GCD of the given set of numbers 2. Write a program to convert the Roman letter to Number 3. Write a program to find the first and last digit of a number. 4. Write a program to check whether the entered character is alphabet or not. 5. Write a program to convert the lower case letter to upper case using macro.

Você também pode gostar