Posts

Showing posts from September 2, 2020

Write a C program to check whether a given string is a palindrome or not.

 Write a C program to check whether a given string is a palindrome or not? A string could be a Palindrome string in C if it remained the same when we reversed it. Let us see how to write a C Program to Check the Given String is Palindrome using Built-in functions, and without using built-in functions. This program for string palindrome in c allows the user to enter a string (or character array), and a character value. Next, it will check whether the user-specified string is a palindrome string or not. /* C Program to Check the given string is Palindrome or not */ #include <stdio.h> #include <string.h> int main() { char str[100]; int i, len, flag; flag = 0; printf("\n Please Enter any String : "); gets(str); len = strlen(str); for(i = 0; i < len; i++) { if(str[i] != str[len - i - 1]) { flag = 1; break; } } if(flag == 0) { printf("\n %s is a Palindrome String", str); } else { printf(...

What is an algorithm? Explain the basic features of an algorithm.

Image
 What is an algorithm? Explain the basic features of an algorithm. The algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. From the data structure point of view, following are some important categories of algorithms − Search − Algorithm to search an item in a data structure. Sort  − Algorithm to sort items in a certain order. Insert  − Algorithm to insert item in a data structure. Update  − Algorithm to update an existing item in a data structure. Delete  − Algorithm to delete an existing item from a data structure. Characteristics of an Algorithm Not all procedures can be called an algorithm. An algorithm should have the following characteristics − Unambiguous  − Algorithm should be clear and unambiguous. Each of its steps (o...

DEVELOP AN ALGORITHM, FLOWCHART, AND PROGRAM TO ADD TWO NUMBERS?

Image
 DEVELOP AN ALGORITHM, FLOWCHART, AND PROGRAM TO ADD TWO NUMBERS? Step 1: Start Step 2: Declare variables num1, num2, and sum. Step 3: Read values for num1, num2. Step 4: Add num1 and num2 and assign the result to a variable sum. Step 5: Display sum Step 6: Stop #include<stdio.h> int main() { int num1,num2,sum; printf("\n Enter the first number to be added: "); scanf("%d",&num1); printf("\n Enter the second number to be added: "); scanf("%d",&num2); sum = num1 + num2; printf("\n The sum of two numbers is: %d",sum); return 0; } What do      you think?                I hope, now you have a better understanding of adding two numbers. Comments and suggestions regarding this article are welcome.

WRITE A PROGRAM TO PRINT A MESSAGE ON THE SCREEN

Image
  WRITE A PROGRAM TO PRINT A MESSAGE ON THE SCREEN  #include<stdio.h> #include<conio.h> void main() { clrscr(); //to clear the screen printf(“ ***** Welcome to C Programming ***** ”); getch(); //to stop the screen } THE PROGRAM IS A VERY SIMPLE, A FEW POINTS MUST BE NOTED. Every C program contains a function called main() What do you think? I hope, now you have a better understanding of print a message on the screen. Comments and suggestions regarding this article are welcome.

WHY IS C CALLED AS MIDDLE-LEVEL LANGUAGE?

  WHY IS C CALLED AS MIDDLE-LEVEL LANGUAGE? C is called middle-level language because it actually binds the gap between a machine-level language and high-level languages. A user can use c language to do  System Programming   (for writing operating system) as well as   Application Programming   (for generating a menu-driven customer billing system ). That's why it is called the middle-level language. High level  - Ada, Modula-2, Pascal, COBOL, FORTRAN, BASIC Middle level  - Java, FORTH, Macro-assemble Low level  - Assembler What do you think? I hope, now you have a better understanding of middle-level languages. Comments and suggestions regarding this article are welcome.

WHAT IS THE DIFFERENCE BETWEEN HIGH-LEVEL LANGUAGE LOW LEVEL LANGUAGE?

WHAT IS THE DIFFERENCE BETWEEN HIGH-LEVEL LANGUAGE    LOW LEVEL LANGUAGE? High-Level Languages Low-Level Languages High-Level Languages are easy to learn and understand. Low-Level Languages are challenging to learn and understand. They are executed slower than lower-level languages because they require a translator program. They execute with high speed. They allow much more abstraction. They allow little or no abstraction. They do not provide many facilities at the hardware level. They are very close to the hardware and help to write a program at the hardware level. For writing programs, hardware knowledge is not required. For writing programs, hardware knowledge is a must. The programs are easy to modify. Modifying programs is difficult. A single statement may execute several instructions. The statements can be directly mapped to processor instructions. BASIC, Perl, Pascal, COBOL, Ruby, etc are examples of High-Level Languages. Machine language and Assembly lan...