Telechargé par Ahlem Lehanin

TD-TP1 ALGO

publicité
Ministry of Higher Education and Scientific Research M’HAMED BOUGARA UNIVERSITY –
BOUMERDES FACULTY OF SCIENCES
Serie of TD/TP
sector : Math, DATA-S et MI
Module : ASD1
Teacher : N. Mehibel
Exercise 1 :
Write an algorithm (C program) which displays the number of occurrences of a "car" character
given by the user in a string S read from the keyboard.
Exercise 2 :
Write an algorithm (C program) that reads a character string and checks whether it is palindrome
or not. Remember that a character string is called a palindrome if it reads the same way in both
directions.
Example: “non”, “radar”, “121” are palindromes.
Exercise 3 :
Write a C program that reads two strings and swaps their contents using the following two
methods:
-
With the strcpy function;
Without the strcpy function.
Exercise 4 :
Write an algorithm (C program) that reads two character strings and checks whether the second
is a substring of the first or not..
Example: tout is a subtring of surtout.
Exercise 5 :
Write an algorithm (C program) which allows you to calculate the number of words in a
sentence, knowing that each word in a sentence is separated by the character ‘ ’ (the blank).
Téléchargement