Skip to main content

WHAT IS CSS?ADVANTAGES, SYNTAX.

 CSS PROGRAMMING LANGAUGE                                                                     disadvantages CSS full form is cascade style sheets , which we call it says about how you should display the HTML elements on the screen. CSS tells us the style of the webpage let us take a simple example, if we build a home first we lay out the design that is known as the HTML language. Where the CSS means layout which means giving instructions on how the furniture should be nothing but the CSS. For example if we take PayPal we can see that the background color blue says the CSS background-color property. Netflix is also the best way of saying  CSS property, but if we remove it will be a normal webpage but with the red color and the black plus symbols it looks like the best webpage. Versions of CSS There are differen...

STRINGS IN C?MANIPULATION FUNCTIONS

 WHAT IS STRING:

                                                               
strings
FUNCTIONS

  • Sequence of characters represented as a single entity is nothing but a string, A character array terminated by a null character(\0) is known as a string.
  • For eg:- char name[5]="good"; we can write a string first define the data type that is char, and declare the variable that names, with size 5 equal to double codes good.
  • There many ways to create a string, the first one is to define the size [5], the second method is without size, third is to give with predefined size. 

C PROGRAM CREATE STRING, DISPLAY IT.

 #include<stdio.h>
 main()
{
 char name[]={"p", "o", "s", "i", "t", "i", "v", "e"};
 int i=0;
 while(name[i]='\0')
 {
  printf("%c",name[i]);
  i++;
 }
}
  • Firstly declare the stdio. h, then the main function declares the char data type, and name variable within the curly brackets write the words and by using the while loop check it if executes do incrementation.

PROGRAM PROMPT USER NAME, DISPLAY IT

#include<stdio.h>
main()\
{
 char name[42];
 printf("enter your name:");
 scanf("%s",name);
 printf("your name is %s",name);
}

  • Gets() function is used to store the given string in place of scanf, we use it in strings.
  • If we use user input containing a space in the text, this program takes the next up to the space only in order to remove we use this function.

Program  gets() function 

#include<stdio.h>
main()
{
 char name[42];
 printf("enter your name:");
 gets(name);
 printf("name is %s",name);
}
  • puts() library function is used to display the text we use printf in c programs but in strings.
  • The main thing in this is the gets function which stores the name value and prints it on the monitor.

PUTS() FUNCTION

#include<stdio.h>
main()
{
 char name[6];
 strcpy(name,"hi");
 puts(name);
}
  • Puts functions place the name value and consoles it on the monitor.

String manipulation functions

  • In the header file "string.h", following library functions are provided to deal with strings.
  • There are strcat() this library function appends or adds at the end one string to the other.
          Syntax:- strcat(s1,s2);

      #include<stdio.h>
      void main()
     {
       char s1[]="Hello";
       char s2[]="hi";
       strcat(s1,s2);
       printf("%s",s1);
     }
   
    Output:- "Hello hi"
  • strcpy() library function almost acts as a string assignment operator, It assigns a string literal to a string-type variable, Copies the content of the string to the other.
         #include<stdio.h>
         #include<string.h>
          main()
        {
          char s1[10]="";
          char s2[10]="hello";
          strcpy(s1,s2);
          printf("%s",s1);
        }
  •  This function copies the value double codes and then hello prints it.     
        Output on the console: "Hello"
  • strlen(): This is used to find the length of the string i.e. to find the number of characters in the string.
         #include<stdio.h>
         #include<string.h>
         main()
        {
          char college[]="iii";
          int n=strlen(college);
          printf("length of the string is %d",n);
         }
  • It finds the length of the string we can either give the length or define it while writing the code.
  • strcmp():  Compare two strings for equality if they are equal, this function returns 0.
         #include<stdio.h>
         #include<string.h>
         main()
        {
          char s1[]="hello";
          char s2[]="hi";
          int n=strcmp(s1,s2);
          if(n==0)
            printf("the given strings are equal");
          else  
            printf("not equal');
         }
  • strncpy():  Copies specified number of content from one string to the other.
#include<stdio.h>
#include<string.h>
void main()
{
char str1[30]="hi";
char str2[40]="hello";
strncpy(str1);
strncpy(str2);
printf("%d\n");
}
  • strncat(): Adds the specified content from string to other.
#include<stdio.h>
#include<string.h>
void main()
{
char str1[10]="world";
char str2[20]="hello";
strncat(str2,str1);
}
  • strncmp(): Compares the required number of characters from strings. 
#include<stdio.h>
#include<string.h>
void main()
{
char s1[30];
char s2[10];
if(s1=s2)
{
printf("successfully");
}
else
{
printf("not");
}
  • strstr(): Search for a string in another string.\
#include<stdio.h>
#include<string.h>
void main()
{
 char ch[50]="whats";
 char s4[40]="up";
 if(ch==s4)
{
printf("executed");
}
else
{
printf("not");
}
  • In the previous blogs we learned about different operators and their types of arithmetic, and assignments.



 


                       

Comments

Popular posts from this blog

BASIC PROGRAM IN C LANGUAGE? INCLUDE, HEADER.

SIMPLE PROGRAM TO PRINT NAMES ON                     CONSOLE USING C LANGUAGE #include <stdio.h> which means that <stdio.h> is the header file that says, that standard input and output header file, so every time there is a format writing the c language program that is the starting line of the code. And Include is the command that we use in the program to include the header file <stdio.h> and this file contains the Printf function means to, display any text onto the console. To use the print function, we need to use #include<stdio.h> then only the print function can be accessed otherwise not.   The first line of the code of the program is, #include<stdio.h> this is the most compulsory step we can say in a c program.                                                    ...

ARRAYS IN C?SCALAR VARIABLE,DISADVANTAGES

SCALAR VARIABLE:-                                                       A  scalar variable is that which can hold only one value it is known as a scalar variable. For eg:- int a=10;                          a=30; DISADVANTAGES OF SCALAR VARIABLE :-      Whenever multiple data items are required to be in the computer memory and access those data items scalar variables have 2 limitations: increase code and performance problems. AGGREGATE VARIABLE:- A variable that can hold multiple values(data items) is known as an aggregate variable. WHAT IS AN ARRAY :- An array is an index-based collection of homogenous elements, the array is a collection of  (continuous) memory locations referred to by a common name that can hold multiple values. Is a subscripted variable that can...

WHAT IS C LANGUAGE? USES, COMPILER

C LANGUAGE C language compiler, C is one of the most popular languages in programming,  Dennis M.RITCHIE invented C programming in the year the 1970s,  C is a high-level programming language which means, its instructions are away from the understanding of the processor. There is a small difference between C language and C++ that is c does not provide object-oriented support. C++ gives class-based support(ORS) which means the same as the previous line in this blog. WHY LEARN C  LANGAUGE Learning C language and a compiler will be useful for coding. Especially for making a website with C language. If we learn C++ it will be useful for making a website. This means C language is only used for making a website but C++ is used for adding colors background colors etc. C language is one of the straightforward languages means easily understandable language. USES OF C LANGUAGE While the C language is used, in the creation of hardware devices.  It is also used in the OS, that ...