CSC 111 Introduction To Programming A Questions
CSC 111 Introduction To Programming A Questions
UNIVERSITY EXAMINATIONS
2014/2015 ACADEMIC YEAR
FIRST YEAR SECOND SEMESTER
MAIN EXAMINATION
FOR THE DEGREE OF COMP SCIENCE & BIT
INSTRUCTIONS TO CANDIDATES
Answer Question One in Section A and Any other TWO (2) Questions in Section B
Instructions to candidates:
1
This paper consists of FIVE Questions.
Answer Question ONE [30 Marks] and any other TWO Questions [20 Marks Each].
Write your college number on the answer sheet.
This paper consists of 2 printed pages
Candidates should check the question paper to ascertain that all the pages are printed as
indicated and that no questions are missing.
2
Program1 Program2
#include <stdio.h> #include<stdio.h>
Void main ( ) { void main(){
int i=1; int a=5,b=10;
for (k=1; k<10; k++) swap(&a,&b);
{ printf("%d %d",a,b);
i*=k; }
printf (“%d”, k,” \t”); printf (“%d”, i, “\n”); void swap(int *a,int *b)
} {
printf (“%d”, i); int *temp;
} *temp =*a;
*a=*b;
*b=*temp;
}
Program1 Program 2:
#include<stdio> #include<stdio.h>
int main() int main ()
{ {
int a = 5; int i=1;
switch (a) while ()
{ {
case 1: printf ("%d\n", i++);
printf ("First") if (i>10)
case 2: break;
printf ("Second"); }
case 3 + 2: return ;
printf ("Third");
case 5:
printf("Final");
break;
}
return 0;
}