C Program to allocate Run time Memory For variable in C

C Program to allocate Run time Memory For variable in C


#include
#include
main()
{
int *base; \\ A
int i;
int cnt=0;
int sum=0;
printf("how many integers you have to store \n");
scanf("%d",&cnt);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
if(!base)
printf("unable to allocate size \n");
else
{
for(int j=0;j<=cnt;j++)
*(base+j)=5;
}
sum = 0;
for(int j=0;j<=cnt;j++)
sum = sum + *(base+j);
printf("total sum is %d\n",sum);
free(base);
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)calloc(10,2);
printf("the base of allocation is %16lu \n",base);


}




Related Links :

Manually Memory Allocation By using MALLOC in C

Manually Memory Allocation By using MALLOC in C




#include
#include
main()
{
int *base;
int i;
int cnt=0;
int sum=0;
printf("how many integers you have to store \n");
scanf("%d",&cnt);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
if(!base)
printf("unable to allocate size \n");
else
{
for(int j=0;j<=cnt;j++)
*(base+j)=5;
}
sum = 0;
for(int j=0;j<=cnt;j++)
sum = sum + *(base+j);
printf("total sum is %d\n",sum);
free(base);
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)calloc(10,2);
printf("the base of allocation is %16lu \n",base);


}


Related Links :

Recursive Function in C for addition of given two numbers

Recursive Function in C for addition of given two numbers





#include
int add(int pk,int pm);
main()
{
int k ,i,m;
m=2;
k=3;
i=add(k,m);
printf("The value of addition is %d\n",i);
getch();
}


int add(int pk,int pm)
{
if(pm==0) return(pk);
else return(1+add(pk,pm-1));
}



Related Links :

C Program to calculate length of given string in C without using STRLEN function

C Program to calculate length of given string in C without using STRLEN function



main ( )
{
char s1[6] = “abcde ”;
int cnt = 0;
cnt = cnt_str(s1);
printf( “ total characters are %d \n”, cnt);
}

int cnt_str(char s1[]);
{
int cn = 0;
while ( (cn < 6) && s1[cn]! = ‘\0’) cn++; return(cn); }

Related Links :

interchanging the values of string in C


main ( )
{
char * s1 = “abcd”;
char s2[] = “efgh”;
printf( “%s %16lu \n, s1, s1);
printf( “%s %16lu \n, s2, s2);
s1 = s2;
printf( “%s %16lu \n, s1, s1);
printf( “%s %16lu \n, s2, s2);
}





Related Links :

Program to explain Working of Union in C

Program to explain Working of Union in C





union marks \\ A
{
float perc; \\ B
char grade; \\ C
}
main ( )
{
union marks student1; \\ E
student1.perc = 98.5; \\ F
printf( “Marks are %f address is %16lu\n”, student1.perc, &student1.perc); \\ G
student1.grade = ‘A’’; \\ H
printf( “Grade is %c address is %16lu\n”, student1.grade, &student1.grade); \\ I
}



Related Links :

C Program to Sort the numbers and store them in file using user define function

C Program to Sort the numbers and store them in file using user define function

C Program to Sort the numbers and store them in file using user define function

#include

int bubble(int*,int);
void filewrite();
void avgmarks();
void fileprint();
void filesort();
void rollin();

/*********************** SORTING FUNCTION ***************************/
int bubble(int x[],int n)
{
int hold,j,pass,i,switched = 1;
for(pass = 0; pass < n-1 && switched == 1;pass++) { switched=0; for (j=0;jx[j+1])
{
switched=1;
hold = x[j];
x[j] = x[j+1];
x[j+1]=hold;
}
}
return(0);
}
/*********************** FILE WRITING FUNCTION ******************************/

void filewrite()
{
int roll,ch,mark;
char nam[50];
FILE *fp;
clrscr();
fp = fopen("student.txt","a");
printf("ENTER ROLL NUMBER, NAME , MARKS \n");
ch =1;
while(ch)
{
scanf("%d%s%d",&roll,&nam,&mark);
fprintf(fp,"%d %s %d\n",roll,nam,mark);
printf("\n\n press 1 to continue,0 to stop");
scanf("%d",&ch);
}
fclose(fp) ;
}
/******************** OUTPUTING DATA ON SCREEN***************/
void fileprint()
{
int marks[100],rollno[100],x[100],i;
char name[100][50];
FILE *fp;

clrscr();
fp = fopen("student.txt","r");
i=0;
printf("ROLLNO NAME MARK\n");
while(!feof(fp))
{
fscanf(fp,"%d %s %d\n",&rollno[i],&name[i],&marks[i]);
printf(" %d %s %d\n",rollno[i],name[i],marks[i]);
i=i+1;
}
fclose(fp);
printf("\n\n\nPRESS ANY KEY");
getch();

}
/******************* SORTING FILE ************************/
void filesort()
{ int marks[100],rollno[100],x[100],n,i,j;
char name[100][50];
FILE *fp,*fm;

fp = fopen("student.txt","r");
fm = fopen("marks.txt","w");
i=0;
while(! feof(fp))
{

fscanf(fp,"%d %s %d\n",&rollno[i],&name[i],&marks[i]);
x[i]= marks[i];
i=i+1;
}

n=i;

bubble(x,n);

for(i=0;i

Related Links :

How to make computer beep through C


#include
int main(void)
{
printf("\a");
return 0;
}








PROGRAM 2 :




#include /* beep1.c */
#include
#include

int main(void)
{
int i, j, speed = 2000;

printf("1 \a \n"); /* works with just stdio.h */
Sleep(1000); /* need windows.h */
/* must wait before dings or I won't get ding
I guess 'cause it's working so hard to make it: ) */

printf("2 \n");
putchar(0x07); /* works with just stdio.h */
Sleep(1000);

printf("3 \n");
Beep(2750, speed); /* need windows.h */
Sleep(1000);

printf("4 \n");
_beep(2750, speed); /* need stdlib.h */
_sleep(1000); /* need stdlib.h */


/* I get the same Beep for all of these */

for(i = 400; i <= 2000; i += 400 ) {
for(j = 400; j <= 2000; j += 400) {
printf("Beep(%d, %d) \n", i, j);
Beep(i, j);
/* Beep(200, speed); */
Sleep(1000);
}
}
return 0;
}
/*
Here's where they come from in my mingw - includes directory:
-----
winbase.h
BOOL WINAPI Beep(DWORD,DWORD);
-----
stdlib.h
/ *
* NOTE: Officially the three following functions are obsolete. The Win32 API
* functions SetErrorMode, Beep and Sleep are their replacements.
* /
_CRTIMP void __cdecl _beep (unsigned int, unsigned int);
_CRTIMP void __cdecl _seterrormode (int);
_CRTIMP void __cdecl _sleep (unsigned long);





Related Links :

Program to print letter S by using loops in C

Program to print letter S by using loops in C


#include
#include
void main()
{
int a[15][3],i,j;
clrscr();
for (i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
printf(" ");
for(i=0;i<3;i++)
{
for(j=15;j>11;j--)
{
printf("%d",a[i][j]=0);
}
printf("\n");
printf(" ");
}
printf("\r");
for(i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
}






OUTPUT :

****************
**------------**
******--------**
****
****
****
****--------****
-----------*****
-----------*****
****
****
****
****--------****
***----------***
**-----------***





Program 2 :




#include
#include
void main()
{
int a[15][3],i,j;
clrscr();
for (i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}
printf(" ");
for(i=0;i<3;i++)
{
for(j=15;j>11;j--)
{
printf("%d",a[i][j]=0);
}
printf("\n");
printf(" ");
}
printf("\r");
for(i=0;i<3;i++)
{
for(j=0;j<16;j++)
{
printf("%d",a[i][j]=0);
}
printf("\n");
}


Related Links :

Program to sort country names in C

Program to sort country names in C



#include
#include

#define countryNo 5
#define maxLength 100

void sortNames(char country[countryNo][maxLength])
{
char temp[maxLength];
int i, j;

// bubble sort
for (j = 0; j < countryNo - 1; j++)
{
for (i = 0; i < countryNo - 1; i++)
{
if (strcmp(country[i], country[i + 1]) > 0)
{
strcpy(temp, country[i]);
strcpy(country[i], country[i + 1]);
strcpy(country[i + 1], temp);
}
}
}
}


int main(int argc, char **argv)
{
char country[countryNo][maxLength];
int i;

// enter names
for (i = 0; i < countryNo; i++)
{
printf("Enter name of country #%d: ", i + 1);
gets(country[i]);
}

sortNames(country);

// display
for (i = 0; i < countryNo; i++)
{
printf("%s\n", country[i]);
}

return 0;
}



Related Links :

C Program showing to shC Program showing example of short hand operator

C Program showing example of short hand operator


#include

main( )
{
int a,b,c,d;
printf("ENTER VALUES OF a,b, c, d");
scanf("%d%d%d",&a,&b,&c);
a += b*c+d;
printf("\n a = %d",a);
}


Related Links :

Concept of SCOPE OF VARIABLES in C

Concept of SCOPE OF VARIABLES in C

#include 
main()
{
int i = 10;

{
int i = 0;
for( i=0;i<2;i++)
{
printf("value of i is %d\n",i);
}
}
printf("the value of i is %d\n",i); }



Explanation :
  • The statement block 1 defines the start of block 1.
  • The statement ‘end of block 1’ defines the end of block 1.
  • Statement A defines variable i which has the scope in the entire block 1.
  • The statement block 2 defines the start of block 2.
  • The statement ‘end of block 2’ defines the end of block 2.
  • Statement B defines variable i which is entirely in block 2.
  • The for loop refers i, which can be resolved using two definitions: statement A and statement B.
  • Since the definition of statement B is nearest, the variable is referred using that definition, so the for loop modifies the value of i at statement B.
  • Variable i at statement A and variable i at statement B are two independent variables even though they have the same name. Statement D is outside block 2, so it prints the value of variable i in block 1.

Related Links :

Working of REGISTER VARIABLES in C

Working of REGISTER VARIABLES in C

#include 
main()
{
register int i = 0;

for( i=0;i<2;i++) { printf("value of i is %d\n",i); } }




Explanation :

  • Here the register allocation directive is given for variable i. During execution, i will be allocated a register if it is available; otherwise, i will receive normal memory allocations.
  • You can use a register directive only for variables of the automatic storage class, not for global variables.
  • Generally, you can use register storage for int or char data types.

Related Links :

Program to explain Concept of Storage of EXTERNAL REFERENCES of variable in C

Program to explain Concept of Storage of EXTERNAL REFERENCES of variable in C


#include
#include
extern int i;
main()
{
i =0;
printf("value of i %d\n",i);
}

\\ Program in file f1.cpp

int i =7;




Related Links :

Program to explain Concept of Storage of Variables in memory in c

Program to explain Concept of Storage of Variables in memory in c




#include
int g = 10; \\ A
main()
{
int i =0; \\ B
void f1(); \\ C
f1(); \\ D
printf(" after first call \n");
f1(); \\ E
printf("after second call \n");
f1(); \\ F
printf("after third call \n");

}
void f1()
{
static int k=0; \\ G
int j = 10; \\ H
printf("value of k %d j %d",k,j);
k=k+10;
}


Related Links :

C Program to sort the name by length


#include
#include

int main()
{
char name1[12], name2[12], mixed[25];
char title[20];

strcpy(name1, "Rosalinda");
strcpy(name2, "Zeke");
strcpy(title, "This is the title.");

printf(" %s\n\n", title);
printf("Name 1 is %s\n", name1);
printf("Name 2 is %s\n", name2);

if(strcmp(name1, name2) > 0) /* returns 1 if name1 > name2 */
strcpy(mixed, name1);
else
strcpy(mixed, name2);

printf("The biggest name alphabetically is %s\n", mixed);

strcpy(mixed, name1);
strcat(mixed, " ");
strcat(mixed, name2);
printf("Both names are %s\n", mixed);

return 0;
}



/* Result of execution

This is the title.

Name1 is Rosalinda
Name2 is Zeke
The biggest name alphabetically is Zeke
Both names are Rosalinda Zeke

*/




Related Links :

C Program to be terminated by pressing X key

C Program to be terminated by pressing X key


#include "stdio.h"
#include "conio.h"

int main()
{
int c;

printf("Enter any characters, terminate program with X\n");

do
{
c = _getch(); /* get a character */
putchar(c); /* display the hit key */
} while (c != 'X');

printf("\nEnd of program.\n");

return 0;
}



/* Result of execution

Enter any characters, terminate program with X

(The output depends on the characters you type in.)

End of program.

*/



Related Links :

C Program to swap memory address by using pointers




main()
{
int a, b, *p1, *p2, x, y, z;
clrscr();
a=10;
b= 5;
p1=&a;
p2=&b;
x= *p1 * *p2 -6;
y= 4 * - *p1 / *p2 + 10;
printf("Address of a: %u\n",p1);
printf("Address of b: %u\n",p2);
printf("\na: %d, b: %d\n",a,b);
printf("X: %d, y: %d\n",x,y);
*p2=*p2+3;
*p1=*p2-5;
z= *p1 * *p2-6;
printf("\na: %d, b: %d",a,b);
printf("\nz: %d", z);
getch();
}



Related Links :

C Program to sort the marks of students in pre defined array

C Program to sort the marks of students in pre defined array



#include
void sort(int m, int x[]);
main()
{
int i;
int marks[5]={40, 90, 73, 81, 35};
clrscr();
printf("Marks before sorting\n");
for(i=0; i<5; i++)
printf("%4d", marks[i]);
printf("\n\n");
sort(5,marks);
printf("Marks after sorting\n");
for(i=0; i<5; i++)
printf("%4d", marks[i]);
printf("\n");
getch();
}
void sort(int m, int x[])
{
int i, j, temp;
for(i=1; i<=m-1; i++)
{
for(j=1;j<=m-1;j++)
{
if(x[j-1]>=x[j]
{
temp=x[j-1];
x[j-1]=x[j];
x[j]=temp;
}
}
}
}

Related Links :

Removing spaces and punctuation from a string in C Language

Removing spaces and punctuation from a string in C Language



#include
#include

#define BUFFER_LEN 500 /* Length of input buffer */

int main(void)
{
char buffer[BUFFER_LEN]; /* Input buffer */
char *pbuffer1 = buffer; /* Pointer to buffer position */
char *pbuffer2 = buffer; /* Pointer to buffer position */

/* Read a string */
printf("Enter a string of up to %d characters:\n", BUFFER_LEN);
while((*pbuffer1++ = getchar()) != '\n')
;
*pbuffer1 = '\0'; /* Append string terminator */
pbuffer1 = buffer; /* Reset pointer to start */
while(*pbuffer1 != '\0') /* Loop until the end of the string */
{
if(ispunct(*pbuffer1) || isspace(*pbuffer1))
{ /* If it's space or puctuation */
++pbuffer1; /* go to the next character */
continue;
}
else
*pbuffer2++ = *pbuffer1++; /* otherwise, copy the character */
}
*pbuffer2 = '\0'; /* Append string terminator */
printf("\nWith the spaces and punctuation removed, the string is now:\n%s\n", buffer);
return 0;
}




Related Links :

C Program to Calculating a floating-point average using pointers

C Program to Calculating a floating-point average using pointers



#include
#include
#include

int main(void)
{
double *values = NULL; /* Pointer to memory holding data values */
double *temp = NULL; /* Pointer to newly allocated memory */
double sum = 0.0; /* Sum of values */
int capacity = 0; /* Maximum number of values that can be stored */
int increment = 5; /* Capacity increment for dynamic allocation */
int count = 0; /* Number of values read */
char answer = 'n';

do
{
if(count == capacity) /* Check if there is spare memory */
{
capacity += increment; /* Increase the capacity of memory by increment */
temp = (double*)malloc((capacity)*sizeof(double)); /* and allocate it */
if(!temp) /* If memory was not allocated */
{ /* Output a message and end */
printf("Memory allocation failed. Terminating program.");
exit(1);
}
if(!values) /* Are there any values? */
values = temp; /* No - so just copy address of new memory */
else /* Yes - so copy data from old to new */
{
for(int i = 0 ; i<=count ; i++)
*(temp + i) = *(values + i);
free(values); /* Free the old memory */
values = temp; /* Copy address of new */
}
temp = NULL; /* Reset pointer */
}

printf("Enter a value: ");
scanf("%lf", values+count++);

printf("Do you want to enter another(y or n)? ");
scanf(" %c", &answer);
}while(tolower(answer) == 'y');

/* Now sum the values */
for(int i = 0 ; i<=count ; i++)
sum += *(values+i);

/* Output the average */
printf("\n The average of the the values you entered is %.2lf.\n", sum/count);
free(values); /* We are done - so free the memory */
return 0;
}




Related Links :

c program to check Looking for palindromes

c program to check Looking for palindromes



#include
#include
#include
int main(void)
{
char sentence[500]; /* Stores the sentence to be tested */
char sentence_chars[500]; /* Stores the sentence without punctuation and spaces */
size_t j = 0; /* Index to character position */
size_t length = 0; /* Length of a string */

printf("Enter a sentence to be tested:\n");
gets(sentence);
/* Copy only letters as lowercase */
for (size_t i = 0 ; i< strlen(sentence) ; i++)
if(isalpha(sentence[i]))
sentence_chars[j++] = tolower(sentence[i]);
sentence_chars[j] = '\0'; /* Append string terminator */

length = strlen(sentence_chars); /* Get the satring length */

/* Compare matching characters in the string */
/* If any pair are not the same, then it's not a palindrome */
for(size_t i = 0 ; i<=length/2 ; i++)
if(sentence_chars[i] != sentence_chars[length-1-i])
{
printf("\n The sentence you entered is not a palindrome.\n");
return 0;
}
/* If we arrive here all matching pairs of characters are equal */
printf("\n The sentence you entered is a palindrome.\n");
return 0;
}




Related Links :

c program to generate A random thought for the day

c program to generate A random thought for the day



#include
#include
#include

int main(void)
{
char thoughts[][50] = {"Wherever you go, there you are!",
"A nod is as good as a wink to a blind horse.",
"Many hands make light work.",
"Too many cooks spoil the broth.",
"A rolling stone gathers no moss.",
"A wise man will cover the hole in his carpet."};

srand((unsigned int)time(NULL));

printf("Today's thought is:\n%s\n", thoughts[rand()%(sizeof thoughts/sizeof thoughts[0])]);
return 0;
}




Related Links :

c program to Analyze comma-separated list of words

c program to Analyze comma-separated list of words

#include 
#include

int main(void)
{
char list[5000];
char words[500][20];
const char comma = ',';
const char space = ' ';
int word_count = 0;
int word_length = 0;
int index = 0;

printf("Enter a comma separated list of words:\n");
gets(list);

while(list[index] != '\0')
{
/* Skip over spaces and commas */
while(list[index] == space || list[index] == comma)
++index;

/* Copy characters that are not space, comma or \0 as part of a word */
while(list[index] != space && list[index] != comma && list[index] != '\0')
words[word_count][word_length++] = list[index++];

words[word_count++][word_length] = '\0';
word_length = 0;
}

/* List the words that were found */
printf("\nThe words in the list are:\n");
for(index = 0 ; index

Related Links :

C Program to Convert an integer to words

C Program to Convert an integer to words

#include 
#include

int main(void)
{
char *unit_words[] = {"zero", "one","two","three","four","five","six","seven","eight","nine"};
char *teen_words[] = {"ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
char *ten_words[] = {"error", "error","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
char hundred[] = " hundred";
char and[] = " and ";
char value_str[50] = "";
int value = 0; /* Integer to be converted */
int digits[] = {0,0,0}; /* Stores digits of value entered */
int i = 0;

printf("Enter a positive integer less than 1000: ");
scanf("%d",&value);
if(value >= 1000)
value = 999;
else if(value < 1) value = 1; while(value > 0)
{
digits[i++] = value%10;
value /= 10;
}

if(digits[2] > 0)
{
strcat(strcat(value_str,unit_words[digits[2]]), hundred);
if(digits[1]>0 || digits[0]>0)
strcat(value_str, and);
}
if(digits[1] > 0)
{
if(digits[1] == 1)
strcat(value_str,teen_words[digits[0]]);
else
{
strcat(value_str,ten_words[digits[1]]);
if(digits[0] > 0)
strcat(strcat(value_str, " "), unit_words[digits[0]]);
}
}
else
if(digits[0] > 0)
strcat(value_str, unit_words[digits[0]]);
printf("\n%s\n", value_str);
return 0;
}





Related Links :

C Program to derive Table of reciprocals, squares, cubes, and fourth powers

C Program to derive Table of reciprocals, squares, cubes, and fourth powers



#include

int main(void)
{
double data[11][5];
double value = 2.0;
int row = 0;
int col = 0;

for(int row = 0 ; row<11 ; row++)
{
data[row][0] = value;
value += 0.1;
}

for(int row = 0 ; row<11 ; row++)
{
data[row][1] = 1.0/data[row][0]; /* 1/x */
data[row][2] = data[row][0]*data[row][0]; /* x*x */
data[row][3] = data[row][2]*data[row][0]; /* x*x*x */
data[row][4] = data[row][3]*data[row][0]; /* x*x*x*x */
}


printf("\n x ");
printf(" 1/x ");
printf(" x*x ");
printf(" x*x*x ");
printf(" x*x*x*x");

for(int row = 0 ; row<11 ; row++)
{
printf("\n");
for(col = 0 ; col<5 ; col++)
printf("%15.4lf", data[row][col]);
}

printf("\n");
return 0;
}





Related Links :

C Program to Summing reciprocals of given five values


#include

int main(void)
{
const int nValues = 5; /* Number of data values */
double data[nValues]; /* Stores data values */
double reciprocals[nValues];
double sum = 0.0; /* Stores sum of reciprocals */

printf("Enter five values separated by spaces:\n");
for(int i = 0 ; i<=nValues ; i++)
scanf("%lf", &data[i]);

printf("\nYou entered the values:\n");
for(int i = 0 ; i<=nValues ; i++)
printf("%10.2lf", data[i]);
printf("\n");

for(int i = 0 ; i<=nValues ; i++)
reciprocals[i] = 1.0/data[i];

for(int i = 0 ; i<=nValues ; i++)
{
sum += reciprocals[i];
if(i>0)
printf(" + ");
printf("1/%.2lf", data[i]);
}
printf(" = %lf\n", sum);
return 0;
}





Related Links :

C Program to Generate a multiplication table using IF and for loops


#include

int main(void)
{
int width = 0;
int height = 0;

printf("Enter the box width and height size separated by a space: ");
scanf("%d", &width);
scanf("%d", &height);

for(int row = 0 ; row<=height ; row++)
{
printf("\n");
for(int col = 0 ; col<=width ; col++)
{
if(row == 0||row==height-1)
{
printf("*");
continue;
}
/* An * in 1st & last column, otherwise a space */
printf("%c", ((col==0 || col==width-1) ? '*' :' '));
}
}
printf("\n");
return 0;
}





Related Links :

C Program to Displaying printable characters plus whitspace names



#include
#include

int main(void)
{
char ch = 0; /* Character code value */
for(int i = 0 ; i<128 ; i++)
{
ch = (char)i;
if(ch%2==0)
printf("\n");
printf(" %4d",ch);
if(isgraph(ch))
printf(" %c",ch);
else
switch(ch)
{
case '\n':
printf(" newline",ch);
break;
case ' ':
printf(" space",ch);
break;
case '\t':
printf(" horizontal tab",ch);
break;
case '\v':
printf(" vertical tab",ch);
break;
case '\f':
printf(" form feed",ch);
break;
default:
printf(" ");
break;

}

}
printf("\n");
return 0;
}



Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!