Skip to main content

Posts

C Model Question Papers for BCA 1st year Kannur Bharathiar MG Madras Bangalore University

C Model Question Papers for BCA 1st year Kannur Bharathiar MG Madras Bangalore University : Fist Year BCA Model Question Paper for C Programming Language :- Model Question Paper B.C.A. : I Year: Programming using C: Time: 3 Hrs. Max. Marks: 100 SECTION – A 1) Answer the following Questions : 10 x 2 = 20 M a) Define Algorithm. b) Define Identifier. c) What is the Purpose of sizeof() operator. d) Compare while and do-while loops. Justify your answer. e) Define Recursion. f) How can we initialize an array. g) What is the difference between structure and union ? h) Define Pointer variable. i) Define Macro. j) What is the purpose of rewind() function. Section – B Answer the following questions. 4 x 20 = 80 M 2. a) Explain the structure of C program. b) Explain features of C language. (or) c) Describe in brief the operators in C language. d) Write a C program to evaluate the following expression. (a+(b*c)/d) 3. a) Explain control structures with examples. (or) b) Explain different parameter ...

Reverse Digits of a Number in C Program, Number Reverse using Recursion or Array in C Program

Reverse Digits of a Number in C Program, Number Reverse using Recursion or Array in C Program : Example : Write a C program to reverse the digits of a Number. #include<stdio.h> #include<conio.h> void main() { int n,rem,reverse_number=0; clrscr(); printf("Enter an integer number to be reversed :"); scanf("%d",&n); while ( n != 0 ) { rem = n % 10 ; n = n / 10 ; reverse_number = ( reverse_number * 10 ) + rem ; } printf("Reverse Number is %d\n",reverse_number); getch(); } Example : c program to reverse the digits of a number using recursion. #include<stdio.h> #include<conio.h> void reverse_Number(int); void main() { int num ; clrscr(); printf("Enter number : "); scanf("%d", & num); printf("\nNumber Reverse = "); reverse_Number(num); getch(); } void reverse_Number(int num) ...

C Code Shortening Techniques or My Logic for Reduced Source Code Writing in C Program Language

C Code Shortening Techniques or My Logic for Reduced Source Code Writing Tips and Tricks in C Program Language :- Role of Semi Colon(;) and Curly Braces({ }) in C Program Perhaps, you might have heard that the for() loop should not end with ";" like if(). But, in fact the ";" is using in C language as a Statement Terminator, so, if we want to terminate for() loop, then we should use ";" at the end of for() loop. [ Header files are to be included as usual, it is not written in the examples ] Question : write a C program to print 1 to 10 numbers using for() loop ? Example 1 : void main() { int i; for ( i = 1 ; i <= 10 ; i++ ) { printf("%d\n",i); } } /* above program, for() loop has one statement outside, so we do not use ";" at the end, because if we put ";" the for() will not take the continuing statement as its own. */ Example 2 : void main() { int i; for ( i = 1 ; i <= 10 ; printf( "%d \n" , i ...

Insertion Sort in C Program with Algorithm and Function Code Reducing Techniques

Insertion Sort in C Program with Algorithm and Function Code Reducing Techniques : Example for Insertion Sorting in C Language Program with Explanations is given below :- Insertion Sorting Algorithm : Every repetition of insertion sort removes an element from the input data, inserting it into the correct position in the already-sorted list, until no input elements remain. The choice of which element to remove from the input is arbitrary, and can be made using almost any choice algorithm. Sorting is typically done in-place. The resulting array after k iterations has the property where the first k + 1 entries are sorted. In each iteration the first remaining entry of the input is removed, inserted into the result at the correct position, thus extending the result: #include<stdio.h> #include<conio.h> void insertion_Sort(int, int []); /* function prototype declaration */ void main() { int arr[100] , a , n ; clrscr(); printf("Enter the number of array elements to be Sor...

Quick Sort in C Code with Algorithm using Recursion and Code Reducing Techniques

Quick Sort in C Code with Algorithm using Recursion and Code Reducing Techniques : Example for Quick Sort Program in C using Recursion with Algorithm is given below :- Algorithm : Quicksort is a divide and conquer algorithm. Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quicksort can then recursively sort the sub-lists. Pick an element, called a pivot, from the list. Reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation. Recursively sort the sub-list of lesser elements and the sub-list of greater elements. The base case of the recursion are lists of size zero or one, which never need to be sorted. #include<stdio.h> #include<conio.h> void quick_Sort( int [], int, int ); /* functi...

C Palindrome String using Pointers Example, C Program to find String Palindrome or not.

C Program for Palindrome String using Pointers Example, C Program to find String Palindrome or not? Example : Write a Program to print a String Palindrome or not in C Language is given below:- #include<stdio.h> #include<conio.h> #include<string.h> int string_Palindrome(char* str) { int i,len; len = strlen(str); for( i = 0 ; i < len / 2 ; i++ ) { if( *(str + i ) != *(str + len - i - 1) ) return 0; } return 1; } void main() { char string[100]=""; clrscr(); printf("Enter a string :"); gets(string); if( string_Palindrome(string)) printf("\n%s is a palindrome",string); else printf("\n%s is not a palindrome",string); getch(); }

Binary Search use Recursion in C or C Program for Binary Search using Array Passing UDF

Binary Search using Recursion function in C or C Program for Binary Search using Array Passing User Defined Function :- Example : How to write C Program for Binary Search using Recursive Function and its solutions given below :- #include<stdio.h> #include<conio.h> int binarySearch(int lmt[],int arrayStart,int arrayEnd,int a) /* UDF declar with definition */ { int m,pos; if (arrayStart<=arrayEnd) { m=(arrayStart+arrayEnd)/2; if (lmt[m]==a) return m; else if ( a < lmt[m] ) return binarySearch(lmt,arrayStart,m-1,a); /* function calls itself called Recursive function */ else return binarySearch(lmt,m+1,arrayEnd,a); /* function calls itself called Recursive function */ } return -1; } void readArray(int lmt[],int n) /* UDF declar with definition */ { int i; printf("Enter the array elements :\n"); for( i=0 ; i < n ; i++ ) scanf("%d",&lmt[i]); } /* main() function starts here */ void main()...