Complete C Exam Solve As much As you can
Q1:choose the correct answer:
1.What will be the output of the program ?
#include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit={1, 2, 13};
printf("%d, %d, %dn", bit.bit1, bit.bit3, bit.bit4);
return 0;
}
A. 1, 2, 13
B. 1, 4, 4
C. -1, 2, -3
D. -1, -2, -13
2. What will be the output of the program (sample.c) given below if it is executed from the command
line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("%d %s", argc, argv[1]);
return 0;
}
A. 3 Good
B. 2 Good
C. Good Morning
D. 3 Morning
3.What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
int i, n;
char *x="Alice";
n = strlen(x);
*x = x[n];
for(i=0; i<=n; i++)
{
printf("%s ", x);
x++;
}
printf("n", x);
return 0;
}
A. Alice
B. ecilA
C. Alice lice ice ce e
D. lice ice ce e
4.What will be the output of the program?
#include<stdio.h>
int addmult(int ii, int jj)
{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}
int main()
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d, %dn", k, l);
return 0;
}
A. 12, 12
B. 7, 7
C. 7, 12
D. 12, 7
5.What will be output when you will execute following code?
static extern int a=5;
static int b=6;
main()
{
printf("%d",a);
printf("%d",b);
return 0;
}
(A) a=0 b=6
(B) a=5 b=0
(C) a=5 b=6
(D) none of these
6.main ()
{
int i, j, k;
i = 3;
j =2*(i++);
k =2*(++i);
}
which one of the given option is correct?
(A) j = 6, k = 10.
(B) i = 5, k = 6
(C) j = 6, k = 8.
(D) i = 4, j = 6.
7.What will be the output
main()
{
if(1,0)
{
printf("True");
}
else
{
printf("False");
}
}
(A) True
(B) False
(C) Compilation Error
(D) Run time Error
8.What will be the output
main()
{
int i, j, *ptr, *ptr1;
i = 10;
j = 10;
ptr = &i;
ptr1 = &j;
if(ptr == ptr1)
{
printf("True");
}
else
{
printf("False");
}
}
(A) True
(B) False
(C) Syntax Error
(D) Run time Error
9. What will be output of the following c program?
#include "stdio.h"
int main()
{
int _ = 5;
int __ = 10;
int ___;
___ = _ + __;
printf("%i", ___);
return 0;
}
(A) 5
(B) 10
(C) 15
(D) Compilation Error
10.What will be the output
main()
{
int i;
i = 10;
if(i == 20 || 30)
{
printf("True");
}
else
{
printf("False");
}
}
A. True
B. False.
C.compilation Error
D.runtime Error
__________________________________
Q2:
1-Write a program that takes two numbers x, y and a choice letter c to select between different mathematical
operations. c may take (+, -, * and /) values, otherwise the program should prints an error and repeat the request. If
the user supplies the right choice the program should performs the operation and prints the result.
2-Given the following array, write a program that reverses all array elements then get max value and average of
these elements and finally prints them. int x[] = {1,2,3,4,5,6,7,8,9,10};
4. write C Program to Store Information Using Structures with Dynamically Memory Allocation.
5.Write C program to get the power of any number entered by user using recursion and iteration
methods.
((((With my best Wishes)))

C exam

  • 1.
    Complete C ExamSolve As much As you can Q1:choose the correct answer: 1.What will be the output of the program ? #include<stdio.h> int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1, 2, 13}; printf("%d, %d, %dn", bit.bit1, bit.bit3, bit.bit4); return 0; } A. 1, 2, 13 B. 1, 4, 4 C. -1, 2, -3 D. -1, -2, -13 2. What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)? cmd> sample Good Morning /* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { printf("%d %s", argc, argv[1]); return 0; } A. 3 Good B. 2 Good C. Good Morning D. 3 Morning
  • 2.
    3.What will bethe output of the program ? #include<stdio.h> #include<string.h> int main() { int i, n; char *x="Alice"; n = strlen(x); *x = x[n]; for(i=0; i<=n; i++) { printf("%s ", x); x++; } printf("n", x); return 0; } A. Alice B. ecilA C. Alice lice ice ce e D. lice ice ce e 4.What will be the output of the program? #include<stdio.h> int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %dn", k, l); return 0; } A. 12, 12 B. 7, 7 C. 7, 12 D. 12, 7
  • 3.
    5.What will beoutput when you will execute following code? static extern int a=5; static int b=6; main() { printf("%d",a); printf("%d",b); return 0; } (A) a=0 b=6 (B) a=5 b=0 (C) a=5 b=6 (D) none of these 6.main () { int i, j, k; i = 3; j =2*(i++); k =2*(++i); } which one of the given option is correct? (A) j = 6, k = 10. (B) i = 5, k = 6 (C) j = 6, k = 8. (D) i = 4, j = 6. 7.What will be the output main() { if(1,0) { printf("True"); } else { printf("False"); } } (A) True (B) False
  • 4.
    (C) Compilation Error (D)Run time Error 8.What will be the output main() { int i, j, *ptr, *ptr1; i = 10; j = 10; ptr = &i; ptr1 = &j; if(ptr == ptr1) { printf("True"); } else { printf("False"); } } (A) True (B) False (C) Syntax Error (D) Run time Error 9. What will be output of the following c program? #include "stdio.h" int main() { int _ = 5; int __ = 10; int ___; ___ = _ + __; printf("%i", ___); return 0; } (A) 5 (B) 10 (C) 15 (D) Compilation Error
  • 5.
    10.What will bethe output main() { int i; i = 10; if(i == 20 || 30) { printf("True"); } else { printf("False"); } } A. True B. False. C.compilation Error D.runtime Error __________________________________ Q2: 1-Write a program that takes two numbers x, y and a choice letter c to select between different mathematical operations. c may take (+, -, * and /) values, otherwise the program should prints an error and repeat the request. If the user supplies the right choice the program should performs the operation and prints the result. 2-Given the following array, write a program that reverses all array elements then get max value and average of these elements and finally prints them. int x[] = {1,2,3,4,5,6,7,8,9,10}; 4. write C Program to Store Information Using Structures with Dynamically Memory Allocation. 5.Write C program to get the power of any number entered by user using recursion and iteration methods. ((((With my best Wishes)))