Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Showing posts with label C-Strings. Show all posts
Showing posts with label C-Strings. Show all posts

Saturday, February 19, 2011

C28 : Display a string(Using user defined functions)

Back to Home   &  C


//Program to display a string using user defined functions.


#include<stdio.h>
#include<conio.h>
display();
void main()
{
clrscr();
getch();
}
int display()
{
printf("Welcome");
return(0);
}
---------------------------------------------------------
Output
Welcome
===============================================
Back to Home   &  C

C27 : Manipulate strings(using string library functions)

Back to Home   &  C


//Program to manipulate string using library functions.

#include<stdio.h>
#include<conio.h>
void main()
{
char s1[20];
char s2[20];
int l;
clrscr();
printf("Enter two strings\n");
scanf("%s%s",s1,s2);
l=strlen(l);
printf("Length of string=%d\n",l);
strcat(s1,s2);
printf("Combined string=%s",s1);
getch();
}
---------------------------------------------------------------
Output
Enter two strings
Welcome
C
Length of the string=7
Combined string=Welcome C
===============================================

//Error in output
Back to Home   &  C

Thursday, February 10, 2011

C10 : Read a string and print it


Back to Home   &  C


A ))) //Read a string and print it

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char n[20];
printf("Enter your name\n");
scanf("%s",n);
printf("Welcome %s",n);
getch();
}
--------------------------------------------------------------------
Output
Enter your name
IGNOU
Welcome IGNOU
=============================================
B ))) //Print a string 5 times (Using While Loop)


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i=1;
while(i<=5)
{
printf("Hai\n");
i++;
}
getch();
}


--------------------------------------------------------------------
Output
Hai
Hai
Hai
Hai
Hai
=============================================
C ))) //Print a string n times (Using for Loop)



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n;
printf("Enter limit value\n");
scanf("%d",&n);
for(i=0;i<=n;i++)
 {
 printf("IGNOU\n");
 }
getch();
}


--------------------------------------------------------------------
Output
Enter limit value
4
IGNOU
IGNOU
IGNOU
IGNOU
=============================================

Back to Home   &  C