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

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

No comments: