Thursday, July 21, 2011

C Programs for printing integers,floating points,character and strings

These are the samples program to understand how to print the integers, floating points , characters and variables......
C language program to print strings.

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("my name is %s and i am a student of %s","ammarafzalkhan","BSCS");
getch();
}

C program to print string and integers.

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("I am a student of class %s and my roll number is %d ","BSCS",014);
getch();
}

OR



#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("%s is %d million miles\nfrom the sun.", " venus",67);
getch();
}


C language program to print floating points.
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("the value of pye is %f ",3.14567);
getch();
}

C language program to print set column floating points.

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("the value of pye is %.2f ",3.14567);  //this will print only two digits after decimal point
getch();
}

C language program to print two strings.
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("my name is %s\n i am a student of %s","ammarafzalkhan","BSCS");
getch();
}

C language program to print character and strings.
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
printf("the letter %c is",'j');
printf("pronounced %s","jay");
getch();
}





No comments:

Post a Comment