Posts

Format Strings

                                   Format Strings Format strings are used to define printing or scanning  value belong to which data type. Data Types Format String int %d unsigned int %u float %f long %ld unsigned long %lu double %lf long double %lf char %c / %s unsigned char %c / %s Example:- #include<conio.h> void main() int i=10; float f=10.5; char c='s'; char s[10]="hellow"; printf("\n Integer : %d",i); printf("\n Float : %f",f); printf("\n Character : %c",c); printf("\n String : %s",s); getch();

What are Header files?

        Header file contains different predefined functions, which are required to run the program. All header files should be included explicitly before main ( ) function.Header files are also called as Pre-compiled header. Here is some C programming header files ... <assert.h> <complex.h>  <ctype.h> <errno.h>   <fenv.h>   <float.h>   <graphic.h> <inttypes.h> <iso646> <limits.h> <locale.h> <math.h>   <process.h> <setjmp.h>   <signal.h> <stdalign.h> <stdatomic.h> <stdbool.h>  <stdarg.h> <stddef.h> <stdint.h>  <stdio.h>   <stdlib.h> <stdnoreturn.h>  <string.h> <threads.h>  <tgmath.h>   <time.h> <uchar.h> <wchar.h> <wctype.h> We can input using two methods 1. #include<Header file name >      example: #include<stdio.h> 2. #include &qu

C Program to convert string into ASCII values in c programming language

#include<stdio.h> int main(){ char str[100]; int i=0; printf("Enter any string: "); scanf("%s",str); printf("ASCII values of every characters of string: "); while(str[i]) printf("%d ",str[i++]); return 0; } Enter any string:ankit c guru ASCII values of every characters of string: 97 110 107 105 116

C program to change Upper case to lower case

/*by ankit gehlot website:ankitcguru.blogspot.com/ */ #include<stdio.h> int main(){ char str[20]; int i=0; printf("Enter any string :"); scanf("%s",str); while(str[i]!='\0'){ if(str[i]>=65&&str[i]<=97){ str[i]=str[i]+32;}i++; } printf("\nThe string in lowercase is :%s ",str); return 0; } Output:- Enter any string :ANKIT The string in lowercase is :ankit

C program to change lower case to upper case

/*by ankit gehlot website:ankitcguru.blogspot.com/ */ #include<stdio.h> int main(){ char str[20]; int i=0; printf("Enter any string :"); scanf("%s",str); while(str[i]!='\0'){ if(str[i]>=97&&str[i]<=122){ str[i]=str[i]-32;}i++; } printf("\nThe string in Upper case is :%s",str); return 0; } Output:- Enter any string :ankit The string in lowercase is :ANKIT

C program to print length of string

         C program to print length of string include<stdio.h> void main(){ char str[15]; int=0; printf("Enter any string :\t");  scanf("%s",&str); while(str[i]!='\0') { i++; printf("\nLength of string :\t%d",i); getch(); } Output:- Enter any string :      ankit c guru Length of string :      12 Note:- Compiler will also count blank spaces between words while compiling.

String

Image
                                                                    String String is a set(array) of character which is terminated by '\0'(null character). When compiler assigns string to character array then it automatically supplies null character ('\0') at the end of string. Thus, size of string = original length of string + 1. Declaration of string:-     char <string name>[roof character]; Example:-   char str[15]; Initialization of strings:-    char str[15]="ankit"; //or char str[15]={'a','n','k','i','t','\0'};//you must put '\o'(null)in this method //printing printf("%s",str);// string printing printf("%c",str[i]);// character printing //scanning scanf("%s",&str);// string scanning scanf("%c",&str[i]);// character scanning