Posts

Excercise in C: Smallest Positive Number

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Excercise in C: Prime Factors

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?

Excercise in C: Fibonacci Sequence

Problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Excercise in C: String Array with Pointer

Write a Program which will take input as string from terminal after that it will perform arithmetic operation as like calculator. Use Pointer and Array in C. Sample input and output is given below: input : (24/7)+2 output : 5.428

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