C Program to demonstrate sscanf statement.

C Program to demonstrate the ‘sscanf’ statement.
sscanf statement reads formatted data from the string, Different syntax of sscanf are:
A = sscanf(str, format)
A = sscanf(str, format, sizeA)
[A, count] = sscanf(…)
[A, count, errmsg] = sscanf(…)
[A, count, errmsg, nextindex] = sscanf(…).Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

main()
{
char Host[64];
char User[64];
char *Buff = "Jobname=job1 Hostname=arnamul User=leslim Time=11:15";
/* <----------> <-----> <---------> <-------->
* | | | |
* | ------------ | |
* | | ------------------ V
* | | | NULL
* V V V */
sscanf (Buff, "%*s Hostname=%s %s", Host, User);

printf("Host is %sn", Host);
printf("User is %sn", User);
exit(0);
}


Read more c programs 
C Basic
C Strings
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to demonstrate sprintf statement.

C Program to demonstrate the ‘sprintf‘ statement. This example is a bit lame as the same effect can be seen with a ‘printf’. But, it does show a string being built and passed into a function. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

main()
{
int i=1; /* Define an integer variable. */
char message[80]; /* Text string */

/* format text and put into 'message' this a great
* improvement over using 'strcpy' and 'strcat' to
* build a text string.
*/
sprintf (message, "i is %i", i);
/* I may be stating the obvious but a '' is
* put on the end of the string. */

puts(message); /* Display message */

}

Read more c programs 
C Basic
C Strings
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to print ASCII values of all characters.

C Program to print ASCII values of all characters.
ASCII value is the American Standard Code for Information Interchange.
ASCII value is the numerical value, or order, of an character. There are 128 standard ASCII characters, numbered from 0 to 127. Extended ASCII adds another 128 values and goes to 255. The numbers are typically represented in decimal or in hexadecimal. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
int main(){

int i;
clrscr();
for(i=0;i<=255;i++)
printf("ASCII value of
character %c: %dn",i,i);
getch();
return 0;

}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to find the strong number.

Write a C Program to find the given number is strong or not?
A number is called strong number if sum of the factorial of its digit is equal to number itself.
Example: 145 since 1! + 4! + 5! = 1 + 24 + 120 = 145.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/
#include<stdio.h>
#include<conio.h>

int main()
{
int num,i,f,r,sum=0,num1;
clrscr();
printf("Enter a number: ");
scanf("%d",&num);

num1=num;
while(num){
i=1,f=1;
r=num%10;

while(i<=r){
f=f*i;
i++;
}
sum=sum+f;
num=num/10;

}
if(sum==num1)
printf("%d is a strong number",num1);
else
printf("%d is not a strong number",num1);
getch();
return 0;

}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

K & R C Programs Exercise 4-7.

K and R C, Solution to Exercise 4-7:
K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition). You can learn and solve K&R C Programs Exercise.
Write C program that will push back an entire string onto the the input.
ungets calls the routine ungetch len times, each time pushing back a character from the string s onto the input. ungets pushes the string back in reverse order.
The routine ungets does not need to worried about the buf and bufp. The routine ungetch handles buf, bufp, and error handling. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
/*ungets: push string back onto the input*/

void ungets(char s[])
{
int len=strlen(s);
void ungetch(int);
while (len >0)
ungetch(s[--len]);
}
int main(void)
{
char *s = "oh! this is for testing!";
int c;

ungets(s);
while ((c = getch()) != EOF)
putchar(c);
return 0;
}
Read more Similar C Programs
C Basic
C Strings
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to print factors of the number.

Write a C Program to print factors of a number. Factors of a whole number are the whole numbers which are exactly divides the number. i.e reminder is equal to zero.
Example: Factors of 8 are: 1, 2, 4, and 8.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#include<conio.h>
{
void main( )
{
int num,x;
clrscr( );
printf("Enter the required number:");
scanf("%d",&num);
printf("nThe factors are:");
for(x=1; x<=num; x++)
{
if(num%x==0)
printf("n%d",x);
}
getch( );
}
Read more Similar C Programs
C Basic
C Search Algorithms
K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

K & R C Programs Exercise 2-2.

K and R C, Solution to Exercise 2-2:
C Program to demonstrate for and while loops. K and R C Program. Exercises provides the solution to all the exercises in the C Programming Language, second addition, by Brian W.Keringhan and Dennis M.Ritchie(Prentice Hall,1988). You can learn and solve K&R C Programs Exercise. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

/*Write the equivalent to the below for loop without using && or ||.*/

// Original

for(i=0; i<lim-1 && (c=getchar()) != 'n' && c != EOF; ++i)
{
s[i] = c;
}
// Equivalent:


while (i < (lim - 1))
{
c = getchar();

if (c == EOF)
break;
else if (c == 'n')
break;

s[i++] = c;
}

Read more Similar C Programs
C Basic

K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

K & R C Programs Exercise 1-23.

K and R C, Solution to Exercise 1-23: C program that removes the all comments from a C Program. K and R C Program. Exercises provides the solution to all the exercises in the C Programming Language, second addition, by Brian W.Keringhan and Dennis M.Ritchie(Prentice Hall,1988). You can learn and solve K&R C Programs Exercise. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include "stdio.h"
void rcomment(int c);
void in_comment(void);
void echo_quote(int c);
main();
{
int c ,d;
while((c= getchar()) !=EOF)
rcomment(c);
return 0;
}
void rcomment(int c) {
int d;
if(c == '/')
if((d= getchar))=='*')
in_comment();
else if(d== '/') {
putchar(c);
rcomment(d);
} else {
putchar(c);
putchar(d);
}
else if(c=='' || c=='"')
echo_quote(c);

}
void in_comment() {
int c, d;
c = getchar();
d = getchar();
while (c!= '*' || d!!='/') {
c = d;
d = getchar();
}
}
void echo_quote(int c) {
int d;
putchar(c);
while ((d = getchar()) != c) {
putchar(d);
if (d == '\')
putchar(getchar());

}
putchar(d);
}
Read more Similar C Programs
C Basic

K and R C Programs Exercise

You can easily select the code by double clicking on the code area above. To get regular updates on new C programs, you can Follow @c_program
You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link

(c) www.c-program-example.com

K&R C Program Exercise 1-11

K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language, second addition, by Brian W.Keringhan and Dennis M.Ritchie(Prentice Hall,1988). You can learn and solve K&R C Programs Exercise. How would you test the word count program? What kinds of input are most likely to uncover bugs if there are any?. Read more about C Programming Language .

To test the word count program try some of the following inputs: 

1. input file contains zero words , output should be 0, 0, 0.
2. input file contains 1 enormous word without any newlines
3. input file contains all white space without newlines
4. input file contains 66000 newlines
5. input file contains word
{huge sequence of white space of different kinds}/word
6. input file contains 66000 single letter words,
66 to the line
7. input file contains 66000 words without any newlines


Some boundary conditions are:
-no input
-no words--just new lines
-no words--just blanks,tabs, and new lines
-one word per line--no blanks and tabs
-word starting at the beginning of the line
-word starting after some blanks.

Read more Similar C Programs
C Basic

K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

K&R C Program Exercise 1-09

K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language, second addition, by Brian W.Keringhan and Dennis M.Ritchie(Prentice Hall,1988). You can learn and solve K&R C Programs Exercise. C Program to replacing each string of one or more blanks by a single blank.Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>

int main(void)
{
int ch;
while ((ch = getchar()) != EOF) {
if (ch == ' ') {
putchar(ch);
while((ch = getchar()) == ' ' && ch != EOF)
;
}
if (ch == EOF)
break;

putchar(ch);
}
return 0;
}
Read more Similar C Programs
C Strings

K and R C Programs Exercise

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com