Write a program to demonstrate the use of scanf function.

Though I've already explained about 'scanf' function in my previous examples. I would like to add some of point here. The first executable statement is of-course the 'printf' function. Which is also know as 'prompt message'. Some compilers permit the use of the 'prompt message' as a part of control string in scanf, like

scanf("Enter a number %d", &number);


#include <stdio.h>
main()
{
int number;
printf("Enter an integer number\n");
scanf("%d", &number);
if( number <>
printf("Your number is smaller then 100\n");
else
printf("Your number contains more than two digits\n");
}

Output:

Enter an integer number
54
Your number is smaller than 100

Enter an integer number
108
Your number contains more than two digits

0 comments:

Post a Comment

 

About Me

It's Me!Hi, I'm Moinuddin. I'm a Software Engineer at WIPRO working on Microsoft .NET Technology. I'm interested in a wide range of technology topics, mainly Microsoft including Windows Azure, WCF, WPF, Silverlight and any other cool technology that catches the eye.

Site Info

ProjectCSharp.com is mainly about demonstrating real time examples in different technologies like ASP.NET, WCF, WPF, Silverlight, Azure etc..,

Followers

Help Links

Project CSharp (C#) Copyright © 2011. All Rights Reserved.