Posts

Showing posts from March, 2013

C Quiz : Part-I

1. What is the correct value to return to the operating system upon the successful completion of a program?   A. -1 B. 1   C. 0 D. Programs do not return a value.   2. What is the only function all C programs must contain? A. start() B. system()   C. main() D. program()   3. What punctuation is used to signal the beginning and end of code blocks?   A. { } B. -> and <- C. BEGIN and END D. ( and )   4. What punctuation ends most lines of C code? A. .  B. ; C. : D. '   5. Which of the following is a correct comment? A. */ Comments */ B. ** Comment **   C. /* Comment */ D. { Comment }   6. Which of the following is not a correct variable type? A. float   B. real C. int D. double   7. Which of the following is the correct operator to compare two variables? A. := B. = C. equal   D. == 8. Which of the following is true? A. 1 B. 66 C. .1 D. -1 E. All of the above   9. Which of the following is the boolean

String functions in C

1. C Program to Find the Frequency of Characters in a String 2 . C Program to Reverse a String by Passing it to Function Source Code 1: #include <stdio.h> int main (){ char c [ 1000 ], ch ; int i , count = 0 ; printf ( "Enter a string: " ); gets ( c ); printf ( "Enter a characeter to find frequency: " ); scanf ( "%c" ,& ch ); for ( i = 0 ; c [ i ]!= '\0' ;++ i ) { if ( ch == c [ i ]) ++ count ; } printf ( "Frequency of %c = %d" , ch , count ); return 0 ; } Output Enter a string: md. ahsan arif Enter a frequency to find frequency: a Frequency of a = 3   2:   #include <stdio.h> #include <string.h> void Reverse ( char str []); int main (){ char str [ 100 ]; printf ( "Enter a string to reverse: " ); gets ( str ); Reverse ( str ); printf ( "Reversed string: " ); puts ( s

Sorting and Searching(Data Structures)

Click for: Sorting and Searching Using C