Monday, July 27, 2009

Can some 1 teach me how to use printf?

can u teach me how to use printf? i have an assignment about this.


or can u create a program that will output all the ascii code using printf. by the way im using c++ thanks

Can some 1 teach me how to use printf?
Plz selct this answer as the best one





//program to write ASCII values of all numbers


//By Siddharth Maheshwari


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int a;


clrscr();


for(a=1;a!=255;a++)


printf("the value of %d is %c",a,a);


}
Reply:Why not teach yourself - a whole lot faster and easier!


http://www.cplusplus.com/reference/clibr...
Reply:#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


//these are header files that are used by the program..it contains the library of functions that will be used throughout the program





void main()


//void because your program does not return a value after executing it





{


//curly brackets are used to start and end a program





int asc=1;


int asc2=2;


int asc3=3;





clrscr(); //to clear the entire screen before outputting


printf("The numbers are %d,%d,%d: \n"%26amp;asc,%26amp;asc2,%26amp;asc3);


getch();





}





//the %d represents the integer or decimal that we defined in the first part


//the syntax is like this: printf("your text here",variable);


//don't forget the semicolon ; because it ends the line statement


//the getch(); is used for a special purpose..





//or you can do it in straight manner:








#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





void main()


{


printf("The numbers are :\n 1,2,3");


getch();


}





//without worrying much trouble..


// \n is used to create new line in the program


//these two slash lines are used for commenting..goodluck!


No comments:

Post a Comment